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≥3k \ge 3 independent groups.

The Procedure

Pool all NN observations from the kk groups and assign ranks 1 through NN to the combined data set, using average ranks for tied values. Let RiR_i be the sum of ranks in group ii and nin_i 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.

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.


H=12N(N+1)∑i=1kRi2ni−3(N+1)H = \frac{12}{N(N+1)}\sum_{i=1}^{k}\frac{R_i^{2}}{n_i} - 3(N+1)


Under H0H_0 (all kk populations have the same distribution), HH is approximately χ2\chi^2-distributed with k−1k-1 degrees of freedom.


The approximation is usually described as adequate once each nin_i reaches about 5; with smaller groups the χ2\chi^2 cut-off is only a rough guide and an exact Kruskal–Wallis table or a permutation p-value is preferable. Reject H0H_0 when HH exceeds the critical value for the chosen significance level.

Worked Example

Three groups of size 2 give combined ranks (out of N=6N=6): Group 1 = {2,5}, Group 2 = {3,6}, Group 3 = {1,4}, so R1=7, R2=9, R3=5R_1=7,\ R_2=9,\ R_3=5. Then


H=126(7)(722+922+522)−3(7)=1242(77.5)−21≈1.14H = \frac{12}{6(7)}\left(\frac{7^2}{2}+\frac{9^2}{2}+\frac{5^2}{2}\right) - 3(7) = \frac{12}{42}(77.5) - 21 \approx 1.14


Comparing 1.14 to χ0.05,22=5.99\chi^2_{0.05,2}=5.99, we would fail to reject H0H_0. 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\chi^2 density for df=2df=2, the reference distribution whenever k=3k=3. Its height falls steadily from x=0x=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 HH is unremarkable and a large HH is surprising under H0H_0.

Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test

Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test



Which statement best describes what the Kruskal–Wallis test actually compares across the kk groups?

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

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.

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

Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

A different study, not the one drawn in the figure, compares three independent groups with nA=5n_A = 5, nB=4n_B = 4 and nC=5n_C = 5, so N=14N = 14. Pooled ranking gives RA=30R_A = 30, RB=45R_B = 45 and RC=30R_C = 30, and for these data the Kruskal–Wallis statistic is H=4.50H = 4.50. The graph shows the χ2\chi^2 density with df=k−1=2df = k - 1 = 2, the reference distribution for three groups, and χ0.05,22=5.99\chi^2_{0.05,2} = 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.

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

Chi-Square Reference Density (df = 2) Used by the Kruskal-Wallis Test

Choose an answer

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors