Kruskal–Wallis test and Dunn’s multiple comparisons (Bonferroni vs Holm)
The Kruskal–Wallis test compares three or more independent groups by rank, as a nonparametric alternative to one-way ANOVA. When it says “somewhere there is a difference”, Dunn’s test tells you which pairs differ. This guide works through the numbers, including an example where the choice of Bonferroni or Holm changes the conclusion.
When to use it
- Three or more independent groups (e.g. control and two doses, separate animals)
- Rank all values together and test whether mean ranks differ between groups
- Close to normal → one-way ANOVA + Tukey/Dunnett; skewed or outliers → Kruskal–Wallis + Dunn
- Two groups → Mann–Whitney U test; three or more paired conditions → Friedman test
The Kruskal–Wallis test only answers “is there a difference somewhere?”. Follow it with multiple comparisons to find which pairs differ. For the bigger picture, see choosing a statistical test.
Computing H
With no difference, each group’s mean rank is close to the overall mean (N + 1)/2 and H is small.
Example: three groups
Cytokine concentrations in a control, low-dose and high-dose group (n = 6 each, made up). The high-dose group contains a large value (6.8), and Shapiro–Wilk gives W = 0.755, P = 0.022, suggesting it may not be normal.
| Group | Values | Rank sum | Mean rank |
|---|---|---|---|
| Control | 1.2, 0.9, 1.5, 1.1, 1.3, 1 | 21 | 3.50 |
| Low dose | 2.6, 3.3, 1.6, 4.9, 2.7, 3 | 65 | 10.83 |
| High dose | 2.9, 3.6, 3.2, 6.8, 3.4, 4.1 | 85 | 14.17 |
H = 12 / (18 × 19) × (21² + 65² + 85²) / 6 − 3 × 19 = 12.54 (no ties). With 2 degrees of freedom, P = 0.0019.
The effect size is ε² = H / (N − 1) = 0.74 (0 to 1; roughly the share of rank variation explained by group). For comparison, one-way ANOVA on the same data gives F(2, 15) = 11.38, P = 0.00098.
Dunn’s multiple comparisons
Dunn’s test uses the same ranks as the Kruskal–Wallis test and compares two groups by the difference in mean ranks divided by its standard error.
| Comparison | Mean rank diff. | z | Unadjusted P | Bonferroni | Holm |
|---|---|---|---|---|---|
| Control vs Low dose | 7.33 | 2.38 | 0.017 | 0.052 | 0.035 |
| Control vs High dose | 10.67 | 3.46 | 0.00054 | 0.0016 | 0.0016 |
| Low dose vs High dose | 3.33 | 1.08 | 0.279 | 0.838 | 0.279 |
Look at control vs low dose. The unadjusted P = 0.017 becomes 0.052 with Bonferroni (×3, not significant) but 0.035 with Holm (significant).
Bonferroni vs Holm
Bonferroni multiplies every P by the number of comparisons m (3 here). Holm sorts the P values and multiplies the smallest by m, the next by m − 1, then m − 2, …, never letting an adjusted P fall below the previous one.
| Order | Comparison | Unadjusted P | Holm multiplier | Holm P |
|---|---|---|---|---|
| 1 | Control vs High | 0.00054 | 3 | 0.0016 |
| 2 | Control vs Low | 0.017 | 2 | 0.035 |
| 3 | Low vs High | 0.279 | 1 | 0.279 |
Holm keeps the chance of any false positive at 5% or less, like Bonferroni, but relaxes the threshold after the first comparison, so it is always at least as powerful. Choose one before looking at the data and state it in the Methods.
Comparing with a control only
If the question is only “does each dose differ from control?”, compare just the two control pairs. The correction then uses 2 instead of 3: with Bonferroni, control vs low is P = 0.035 and control vs high is P = 0.0011. It is the same idea as Dunnett’s test after ANOVA (how to do Dunnett’s test).
How to write it in a paper
Methods: “Groups were compared using the Kruskal–Wallis test followed by Dunn’s multiple comparisons test with Holm adjustment.” Results: “Cytokine levels differed among groups (H(2) = 12.54, P = 0.002, ε² = 0.74). Dunn’s test showed higher levels than control at the high dose (P = 0.002) and the low dose (P = 0.035).” Give adjusted P values. A median-based figure such as a box plot or points with the median matches the test.
FAQ
Why not run Mann–Whitney tests on each pair?
Without correction, the chance of a false positive somewhere goes up. With a Bonferroni correction it is possible, but Dunn’s test ranks all groups together and uses the same ranks as the Kruskal–Wallis test, so it is consistent with the overall test.
Kruskal–Wallis was not significant but Dunn found a pair
It can happen; they are different tests. If you planned to look at post hoc tests only after a significant Kruskal–Wallis, follow that plan; otherwise report both results as they are.
If Holm is always at least as good, why use Bonferroni?
Holm controls the same familywise error rate and is never less powerful. Bonferroni is simpler to explain (multiply each P by the number of comparisons) and gives matching simultaneous confidence intervals. Decide in advance.
Why does ANOVA give a different answer?
ANOVA compares means; Kruskal–Wallis compares ranks. Outliers move means and variances a lot but ranks very little. Choose by the nature of the data, and do not switch after seeing the results.
Related guides
Product and journal names are trademarks or registered trademarks of their respective owners.