Kruskal-Wallis Test

The non-parametric analogue of one-way ANOVA — comparing three or more groups using ranks rather than raw values.

Hypothesis test — rejection region and test statistic
z=1.96z=-1.96z=1.80-3-2-10123α/2 = 0.025α/2 = 0.025
✓ Fail to reject H₀ — p-value ≈ 0.0719 > α=0.05
α = 0.05
z = 1.80
Click to toggle
Definition

The Kruskal-Wallis test is the nonparametric analog of one-way ANOVA. It tests whether k≥2k \geq 2 independent groups have the same distribution, without assuming normality.

Null hypothesis: all kk groups have the same distribution (or equivalently, the same population median).

Procedure:

  1. Pool all observations and assign ranks (smallest = 1, handle ties by averaging)
  2. Compute the mean rank for each group: Rˉj=Rj/nj\bar{R}_j = R_j / n_j
  3. Test statistic:

H=12N(N+1)∑j=1kRj2nj−3(N+1)H = \frac{12}{N(N+1)} \sum_{j=1}^k \frac{R_j^2}{n_j} - 3(N+1)

  1. Under H0H_0, H≈χk−12H \approx \chi^2_{k-1} for large samples
Key properties
  • Reduces to the Mann-Whitney U test exactly when k=2k=2 groups
  • Uses only rank information, so it's robust to outliers and doesn't require normality
  • Tests equality of entire distributions, not just medians — differences in spread or shape can also trigger rejection
  • HH is always non-negative, with larger values indicating more uneven rank distribution across groups
Common mistakes
  • Interpreting a significant result as "the medians differ": the null hypothesis is equality of distributions — groups with equal medians but different variances or shapes can still trigger rejection
  • Skipping multiplicity correction for post-hoc comparisons: a significant omnibus result only says some group differs; pairwise follow-ups need correction (Dunn's test or Bonferroni-adjusted Mann-Whitney)
Comparing three teaching methods

Three groups of students (same size nj=5n_j = 5, total N=15N = 15). After pooling and ranking:

  • Method A: ranks {2,5,7,9,11}\{2, 5, 7, 9, 11\}, RA=34R_A = 34
  • Method B: ranks {1,3,6,8,10}\{1, 3, 6, 8, 10\}, RB=28R_B = 28
  • Method C: ranks {4,12,13,14,15}\{4, 12, 13, 14, 15\}, RC=58R_C = 58

H=1215⋅16(342/5+282/5+582/5)−3(16)=12240(925.8)−48≈6.3H = \frac{12}{15\cdot16}(34^2/5 + 28^2/5 + 58^2/5) - 3(16) = \frac{12}{240}(925.8) - 48 \approx 6.3

Compare to χ22=5.99\chi^2_2 = 5.99 (α=0.05\alpha = 0.05): 6.3>5.996.3 > 5.99, reject H0H_0.

Try it

The Kruskal-Wallis test tells you some groups differ. What must you do to determine which groups differ?

Solution

Run post-hoc tests — pairwise Mann-Whitney U tests between groups. But with kk groups, there are (k2)\binom{k}{2} pairs, leading to multiple testing concerns. You must apply a correction such as Bonferroni (adjust α\alpha by dividing by number of comparisons) or Dunn's test (a procedure specifically designed for post-hoc comparisons after Kruskal-Wallis, using the original ranks).

Dunn's test is preferred because it uses the pooled variance from the full Kruskal-Wallis ranking, making it more powerful than separate Mann-Whitney tests with Bonferroni correction.

Related concepts