SPSS command: SPSS NPAR TESTS /K-W
Kruskal-Wallis test in your browser
The Kruskal-Wallis H test is the rank-based alternative to one-way ANOVA: it asks whether three or more independent groups come from the same distribution.
Free · No account · Files stay on your device · Updated 18 October 2026
What it tells you
Crosstabs runs SPSS NPAR TESTS /K-W with a tie-corrected H, the ε² effect size and Dunn pairwise comparisons, and adds the k-sample median test and the Jonckheere-Terpstra test for ordered groups.
- Whether at least one group tends to have higher or lower values than the others (H, df and asymptotic significance).
- How much of the ranking is explained by group membership, as ε² = H/(N − 1).
- Which pairs of groups differ, from Dunn's mean-rank differences with Bonferroni-adjusted significance.
- Whether values rise or fall steadily across groups in a set order (Jonckheere-Terpstra), and whether groups differ in their share of cases above the pooled median (median test).
When to use it
Use it when
- Three or more independent groups compared on an ordinal or skewed outcome, such as satisfaction ratings by region or resolution days by team.
- Group sizes are small or unequal and a normality assumption is hard to defend.
- The groups have a natural order (dose levels, age bands, plan tiers) and you expect a monotonic trend: use Jonckheere-Terpstra.
Use something else when
- Only two groups: use the Mann-Whitney U test, which also gives an exact significance for small samples.
- The same cases measured under every condition: use the Friedman test for related samples.
- Roughly normal outcomes with a need for mean differences and confidence intervals: use one-way ANOVA with Welch and Games-Howell.
- Two or more grouping factors at once: rank-based tests here handle one factor only.
How to run it in Crosstabs
- 01
Choose K independent samples
In Statistics mode open Nonparametric tests → K independent samples (NPAR TESTS /K-W).
- 02
Pick test variables and the grouping variable
Tick numeric outcomes under Test variables, then choose the Grouping variable. All of its values are included by default.
- 03
Select and order the groups
Untick any group to leave it out under Groups included. The order shown is the order Jonckheere-Terpstra tests, so keep the groups in their natural sequence.
- 04
Choose the tests
Under Test type tick Kruskal-Wallis H, Median and/or Jonckheere-Terpstra. Keep Pairwise comparisons (Dunn, Bonferroni-adjusted) ticked to get the post hoc table.
- 05
Run
Choose Exclude cases test-by-test or listwise and click Run test. The interpretation below the tables names the pairs that differ after adjustment.
Worked example
Computed by the Crosstabs engine from the synthetic data below when this page was built — not typed in.
Data
33 synthetic complaints from three regions (North 10, Central 12, South 11); the outcome is whole days to resolution, drawn from right-skewed log-normal curves with a fixed seed.
| region | N | Mean Rank |
|---|---|---|
| North | 10 | 8.05 |
| Central | 12 | 16.21 |
| South | 11 | 26.00 |
| Total | 33 |
| Item | days |
|---|---|
| Kruskal-Wallis H | 18.324 |
| df | 2 |
| Asymp. Sig. | <.001 |
| Effect size ε² = H/(N − 1) | 0.573 |
H is corrected for ties.
| Sample 1-Sample 2 | Test Statistic | Std. Error | Std. Test Statistic | Sig. | Adj. Sig. |
|---|---|---|---|---|---|
| North-Central | −8.158 | 4.124 | −1.978 | .048 | .144 |
| North-South | −17.950 | 4.208 | −4.266 | <.001 | <.001 |
| Central-South | −9.792 | 4.020 | −2.436 | .015 | .045 |
Dunn (1964) mean-rank differences; significance adjusted by the Bonferroni correction.
How to read it
The omnibus test gives H(2) = 18.32, p < .001, ε² = 0.573. After Bonferroni adjustment the pairs that differ are North–South, Central–South. Report the adjusted significance, not the raw one, when you name a pair.
Output tables explained
- Ranks
- N and mean rank of every included group, with the total N.
- Test Statistics — Kruskal-Wallis Test
- Tie-corrected Kruskal-Wallis H, df (groups − 1), asymptotic significance from the chi-square distribution and ε² = H/(N − 1).
- Pairwise Comparisons
- For each pair: the difference in mean ranks, its standard error, the standardized statistic, the raw significance and the Bonferroni-adjusted significance (Dunn, 1964). Use the adjusted column.
- Test Statistics — Median Test
- The pooled median and a chi-square test on the counts above and at-or-below it in each group (shown in Frequencies — Median Test). With two groups Fisher's exact test is used for N ≤ 30.
- Test Statistics — Jonckheere-Terpstra Test
- Observed, mean and standard deviation of the J-T statistic, the standardized J-T and its two-tailed asymptotic significance. A positive standardized value means values increase in the listed order.
Assumptions and notes
- Groups are independent and every case belongs to one group.
- The outcome is at least ordinal; reading H as a difference in medians requires similarly shaped distributions.
- Significance is asymptotic (chi-square). With very small groups (fewer than about five cases each) treat borderline p values with caution.
How the results are validated
The k-sample engines are tested against independent reference values computed with SciPy 1.18.1, statsmodels 0.15.0, pingouin 0.7.0 and scikit-posthocs 0.17.1: Kruskal-Wallis H and p match scipy.stats.kruskal, Dunn pairwise p-values and Bonferroni adjustments match scikit-posthocs posthoc_dunn, the median test matches scipy.stats.median_test and fisher_exact, and Jonckheere-Terpstra is checked against brute-force pair counting. All agree within 1e-9 (relative to the larger of 1 and the reference value). Validation evidence
Questions
What post hoc test follows a significant Kruskal-Wallis result?
Dunn's test on mean ranks, which uses the pooled ranking from the omnibus test. Crosstabs adjusts its p values with Bonferroni (p × number of pairs, capped at 1), as SPSS does in its pairwise comparisons.
How do I report the effect size?
Report ε² = H/(N − 1), shown in the test table. It runs from 0 to 1; values around .01, .08 and .26 are often described as small, medium and large.
Should I run separate Mann-Whitney tests instead of Dunn comparisons?
Running each pair separately re-ranks the data every time and needs its own multiplicity correction. Dunn's comparisons keep one ranking and are adjusted for you, which is the usual follow-up.
When is Jonckheere-Terpstra better than Kruskal-Wallis?
When you predicted a direction across ordered groups before seeing the data, such as outcomes improving with dose. It concentrates its power on that monotonic trend.
Is there an exact p value for Kruskal-Wallis?
Not in this panel: H, the median test chi-square and Jonckheere-Terpstra are reported with asymptotic significance.
Related procedures
- One-Way ANOVAONEWAY
- Mann-Whitney U TestNPAR TESTS /M-W
- Friedman TestNPAR TESTS /FRIEDMAN
- Bayesian One-Way ANOVABAYES ANOVA
- Rank CasesRANK
- MeansMEANS
- Free SPSS alternative: full coverage list
Run Kruskal-Wallis Test on your own data
Open a .sav, CSV or Excel file. Everything runs in your browser; the file never leaves your device.
SPSS is a trademark of IBM Corp. Crosstabs is not affiliated with or endorsed by IBM.