What the Kruskal–Wallis test does
The Kruskal–Wallis H test extends the Mann–Whitney test to three or more independent groups. It is the non-parametric counterpart of one-way ANOVA: instead of comparing means, it compares the average ranks of the groups after all observations have been pooled and ranked from 1 to N. Use it when the data are skewed, ordinal or contain outliers, or when group variances are very unequal.
The formula
H = 12 ÷ (N(N + 1)) × Σ (Rᵢ² ÷ nᵢ) − 3(N + 1)
- Rᵢ is the rank sum of group i and nᵢ its size;
- N is the total number of observations.
When every group has at least five observations, H follows approximately a chi-square distribution with k − 1 degrees of freedom, where k is the number of groups. The calculator also checks that your rank sums add up to N(N + 1) ÷ 2, a quick way to catch a ranking mistake.
Example
Three groups of 6 observations, with rank sums 33, 57 and 81:
- N = 18, and the rank sums total 171 = 18 × 19 ÷ 2, as they should;
- Σ Rᵢ² ÷ nᵢ = (1,089 + 3,249 + 6,561) ÷ 6 = 1,816.5;
- H = 12 ÷ 342 × 1,816.5 − 57 ≈ 6.74, with 2 degrees of freedom;
- p ≈ 0.034: significant at α = 0.05; the critical H is 5.99;
- the effect size η²(H) ≈ 0.32 is large.
How to get the rank sums
- Pool all values and sort them.
- Give rank 1 to the smallest value. Tied values share the average of the ranks they would occupy.
- Add up the ranks of each group.
After a significant result
A significant H says that at least one group differs, not which one. Follow up with pairwise comparisons, such as Dunn’s test or Mann–Whitney tests, with a Bonferroni or Holm correction for the number of comparisons.
Limits
- Groups must be independent. For repeated measurements on the same subjects, use the Friedman test.
- Many ties call for a tie correction, which slightly increases H; the uncorrected value used here is conservative.
- With very small groups (fewer than five each), use exact tables.
- Effect size guidelines for η²(H) follow those of ANOVA: about 0.01 small, 0.06 medium and 0.14 large.