The Kruskal–Wallis Test: A Rank-Based Alternative to One-Way ANOVA
What Is the Kruskal–Wallis Test?
The Kruskal–Wallis test is the non-parametric counterpart to one-way ANOVA. Instead of comparing group means under an assumption of normal, equal-variance populations, it compares group rank sums, which makes it suitable when data are ordinal, skewed, or have unequal spreads across k≥3 independent groups.
The Procedure
Pool all N observations from the k groups and assign ranks 1 through N to the combined data set, using average ranks for tied values. Let Ri be the sum of ranks in group i and ni its sample size. The test statistic is
Combined ranking of three independent groups (N = 10). Each dot shows an observed value with its rank in the pooled sample; the rank sums are not shown.
Under H0 (all k populations have the same distribution), H is approximately χ2-distributed with k−1 degrees of freedom.
The approximation is usually described as adequate once each ni reaches about 5; with smaller groups the χ2 cut-off is only a rough guide and an exact Kruskal–Wallis table or a permutation p-value is preferable. Reject H0 when H exceeds the critical value for the chosen significance level.
Worked Example
Three groups of size 2 give combined ranks (out of N=6): Group 1 = {2,5}, Group 2 = {3,6}, Group 3 = {1,4}, so R1=7, R2=9, R3=5. Then
Comparing 1.14 to χ0.05,22=5.99, we would fail to reject H0. With only two observations per group this is a very low-power comparison, so 'not significant' here means 'no evidence of a difference', not 'the distributions are the same'.
Reading the Reference Curve
The accompanying graph is the χ2 density for df=2, the reference distribution whenever k=3. Its height falls steadily from x=0, so nearly all of its area sits at small values; only a long thin tail reaches past 5.99. That shape is why a moderate H is unremarkable and a large H is surprising under H0.
Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test
The figure shows ten observations from three independent groups laid out in pooled-rank order. Using the ranks assigned to each observation, which group has the largest sum of ranks?
Combined ranking of three independent groups (N = 10). Each dot shows an observed value with its rank in the pooled sample; the rank sums are not shown.
Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test
A different study, not the one drawn in the figure, compares three independent groups with nA=5, nB=4 and nC=5, so N=14. Pooled ranking gives RA=30, RB=45 and RC=30, and for these data the Kruskal–Wallis statistic is H=4.50. The graph shows the χ2 density with df=k−1=2, the reference distribution for three groups, and χ0.05,22=5.99. What should you conclude at the 5% significance level?
Combined ranking of three independent groups (N = 10). Each dot shows an observed value with its rank in the pooled sample; the rank sums are not shown.
Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test