CalculatorsToolsGuides 日本語
BenchFig › Guides › Kruskal–Wallis test and Dunn’s multiple comparisons (Bonferroni vs Holm)
Statistics

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.

Updated: BenchFig日本語

When to use it

Key points
  • 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

H = 12N(N + 1) Σ Ri2ni − 3(N + 1)R_i is the rank sum of group i, n_i its size, N the total. With ties, divide by C = 1 − Σ(t³ − t)/(N³ − N) (t = size of each tie). P comes from the chi-square distribution with k − 1 degrees of freedom.

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.

GroupValuesRank sumMean rank
Control1.2, 0.9, 1.5, 1.1, 1.3, 1213.50
Low dose2.6, 3.3, 1.6, 4.9, 2.7, 36510.83
High dose2.9, 3.6, 3.2, 6.8, 3.4, 4.18514.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.

z = R̄i − R̄j√( N(N + 1)12 (1ni + 1nj) )With ties, subtract Σ(t³ − t)/(12(N − 1)) from N(N + 1)/12. Get the two-sided P from z and adjust for the number of comparisons.
ComparisonMean rank diff.zUnadjusted PBonferroniHolm
Control vs Low dose7.332.380.0170.0520.035
Control vs High dose10.673.460.000540.00160.0016
Low dose vs High dose3.331.080.2790.8380.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).

01234567ControlLow doseHigh doseCytokine (ng/mL)***
Box plot with individual points (made up, n = 6 each). Brackets: Dunn’s test with Holm adjustment. * P < 0.05, ** P < 0.01 (the non-significant low vs high bracket is omitted). The high-dose group has a large value (6.8) and is not close to normal.

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.

OrderComparisonUnadjusted PHolm multiplierHolm P
1Control vs High0.0005430.0016
2Control vs Low0.01720.035
3Low vs High0.27910.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).

Try Kruskal–Wallis and Dunn on a multi-group sampleChoose Nonparametric, then try Bonferroni or Holm under Correction, and all pairs or vs control under Pairs to compare. The graph can also be a box plot.
Open for free →

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.

Try Kruskal–Wallis and Dunn on sample dataOpen a multi-group sample on the Graph screen and set Test type to Nonparametric to see H, P, ε² and Dunn’s comparisons (Bonferroni or Holm, all pairs or vs control).
Open for free →
Your own data, all the way to the final figure.Loading your files, saving, and journal-ready export (PDF, TIFF, PNG, SVG) are in BenchFig Pro for Windows, updated based on researchers’ requests: ¥3,980/year (2 PCs), with lab and perpetual licenses too.
About the app →

Related guides

Product and journal names are trademarks or registered trademarks of their respective owners.