Kruskal-Wallis Test
Compare three or more independent groups by rank — H, degrees of freedom, p, and effect size.
3 groups, N = 15, df = 2. Two or more groups differ if p is below your alpha.
From the chi-square distribution with 2 degrees of freedom.
Epsilon-squared — the proportion of rank variance explained by group membership.
Kruskal-Wallis extends the Mann-Whitney test to three or more groups. For three groups of five with rank sums 15, 40 and 65, H = 12.50 with 2 degrees of freedom, giving p = .002 — at least two groups differ.
Nonparametric one-way ANOVA
One-way ANOVA compares group means and assumes the data are normal with similar variances. The Kruskal-Wallis test asks the same broad question — do these groups differ? — using only the ranks of the observations, which makes it suitable for skewed data, ordinal outcomes, and small samples.
All observations are pooled and ranked together. If the groups come from the same distribution, each group’s rank sum should be proportional to its size. H measures how far the observed rank sums stray from that expectation, and follows a chi-square distribution with k − 1 degrees of freedom when the null hypothesis is true.
What a significant H does and does not say
A significant result means at least one group differs from at least one other. It does not say which, nor how many — exactly like a significant F in ANOVA. Identifying the specific pairs needs a post-hoc procedure such as Dunn’s test with a correction for multiple comparisons.
N is the total sample size, k the number of groups, Rⱼ the rank sum of group j, nⱼ its size, and t the size of each group of tied values.
Worked example: three groups of five
Rank across all fifteen values, then compare the rank sums:
- 1 Pool and rank every value. All 15 observations are ranked together from 1 to 15, with ties sharing an average rank.
- 2 Sum the ranks within each group. The groups separate cleanly here: R₁ = 15, R₂ = 40, R₃ = 65.
- 3 Compute the weighted sum. 15² ÷ 5 + 40² ÷ 5 + 65² ÷ 5 = 45 + 320 + 845 = 1210.
- 4 Apply the formula. 12 ÷ (15 × 16) × 1210 − 3 × 16 = 0.05 × 1210 − 48 = 60.5 − 48 = 12.50.
- 5 Find the p-value. With df = 3 − 1 = 2, a chi-square of 12.50 gives p = .002.
- 6 Follow up. The test says the groups differ; a post-hoc test such as Dunn’s identifies which pairs.
Choosing a test for three or more groups
The nonparametric route trades a little power under normality for robustness when it fails.
| Design | Parametric | Nonparametric |
|---|---|---|
| Three or more independent groups | One-way ANOVA | Kruskal-Wallis H |
| Three or more repeated measures | Repeated-measures ANOVA | Friedman test |
| Two independent groups | Independent t-test | Mann-Whitney U |
| Two paired measurements | Paired t-test | Wilcoxon signed-rank |
| Follow-up comparisons | Tukey HSD | Dunn’s test |
Assumptions, ties, and small groups
Kruskal-Wallis assumes independent observations and that the groups have similarly shaped distributions. Under that condition a significant result can be read as a difference in medians; without it, the conclusion is the weaker but still useful one that the distributions differ.
Ties reduce the variability of the ranks, so H is divided by a correction factor. With coarse scales — a seven-point questionnaire item across a hundred respondents — the correction can change H noticeably, and this calculator applies it automatically.
The chi-square approximation assumes roughly five or more observations per group. With smaller groups, use an exact test rather than the approximate p-value. For reporting, give H, the degrees of freedom, N, the exact p, and an effect size such as epsilon-squared, along with medians and interquartile ranges per group.