Kruskal-Wallis test
The Kruskal-Wallis test compares ranks across independent groups to challenge the hypothesis that their outcome distributions are the same.
Fit
When to use it, and when not to
Use it when
- You have three or more independent groups and outcomes that can be ordered.
- You want an overall rank comparison, with follow-up comparisons planned in advance.
Not when
- The same people supply several visits. Consider repeated-measures ANOVA for a continuous mean question. Read: Repeated-measures ANOVA
- Your target is a difference in means. Use one-way ANOVA when its assumptions fit. Read: One-way ANOVA: testing group means
- You have only two independent groups. Use the Mann-Whitney test. Read: Mann-Whitney U test
Before you start
What you need
- Raw outcomes and group labelsEach independent person contributes one value. Keep tied values and group sizes.
- The clinical target and distribution plotsDecide whether a rank comparison answers the question. Check shape before interpreting a result as a shift in medians.
- Planned comparisons and missing-data handlingChoose multiplicity control before examining results. Justify a missing-data assumption, such as missing completely at random, and assess selection bias.
- Observations are independent within and across groups.How to check: Check for repeated visits or shared wards. Ranking does not remove dependence.
- The usual null hypothesis is a common outcome distribution across groups.How to check: Inspect group plots. Different spreads or shapes can affect ranks even with equal medians.
- The chi-square reference is a large-sample approximation.How to check: Small groups or many ties may need a suitable exact or permutation calculation under the null.
Plain language
How it works
Pool values across groups, rank them and average ties. Compare each group’s rank sum with what a common distribution would predict. Correct the H statistic for ties. Its usual reference is chi-square with one fewer degree of freedom than groups.
Berry and Mielke describe exact and Monte Carlo rank procedures that handle ties without asymptotic probabilities. Clark and colleagues compare power predictions in simulated and medical datasets. Their results do not establish a universal sample-size rule.
Worked example
A worked example
- Setting
- 3 independent groups each contain 5 patients with a symptom score.
- Question
- Are all three score distributions the same?
- Approach
- Group A: 2, 4, 4, 5, 7. Group B: 5, 6, 8, 8, 9. Group C: 8, 9, 10, 12, 12.
- Result
- Among 15 patients, the tie-corrected H = 10.272 with 2 degrees of freedom. The approximate chi-square p = 0.006.
- What it means
- The overall test challenges equal distributions. It identifies no pair and no median difference; small-group approximation and planned follow-up comparisons still need care.
In practice
Recent studies PubMed search · not vetted
Watch out
Common mistakes
The one to remember
Kruskal-Wallis tests equality of distributions through ranks, not equality of means. A median-shift interpretation needs comparable distribution shapes; the overall result identifies no specific pair.
- Calling a significant result proof that every group differs.Instead: Use the planned rank comparisons with a multiplicity adjustment. The overall test identifies no pair.
- Describing the result as a comparison of medians regardless of shape.Instead: Show group distributions. A shared-shape location model is needed for that narrower interpretation.
Inside Mallard
How Mallard uses this
Mallard links this article to its Kruskal-Wallis calculator. It corrects H for ties and uses a chi-square approximation. The method registry links this method to its published analysis article and code.
kruskal-wallis).analysis.kruskal_wallis, the id a plan cue records.How to report it
Report group sizes, distribution summaries, tie-corrected H, degrees of freedom and the probability method. Give planned comparisons with their multiplicity adjustment. If reporting median differences, use an estimator and interval designed for that target. A reporting guideline is not a design manual: use it to make the study transparent, not as a substitute for careful design. Check the target journal's own requirements as well, which this page cannot know.
Work it out
Related Learn pages
Related designs and methods
Evidence
Sources & further reading
- Exact and Monte carlo resampling procedures for the Wilcoxon-Mann-Whitney and Kruskal-Wallis tests (opens in a new tab) · Percept Mot Skills · doi 10.2466/pms.2000.91.3.749
- Empirical investigations into Kruskal-Wallis power studies utilizing Bernstein fits, simulations and medical study datasets (opens in a new tab) · Sci Rep · doi 10.1038/s41598-023-29308-2