Ask Mallard
Analysis method

Kruskal-Wallis test

5 min read

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

Before you start

What you need

Decide these first
  1. Raw outcomes and group labelsEach independent person contributes one value. Keep tied values and group sizes.
  2. The clinical target and distribution plotsDecide whether a rank comparison answers the question. Check shape before interpreting a result as a shift in medians.
  3. 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.
It rests on these
  1. Observations are independent within and across groups.How to check: Check for repeated visits or shared wards. Ranking does not remove dependence.
  2. 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.
  3. 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.

What the sources show

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.

The method at a glance
Kruskal-Wallis test: Independent groups with ordered outcomes. Then Pool ranks and correct for ties. Then Overall H challenges equal distributions.Kruskal-Wallis testIndependent groups with ordered outcomesPool ranks and correct for tiesOverall H challenges equal distributions
Conceptual diagram. It shows the structure of the idea, not data from any study.

Worked example

A worked example

Invented for illustration
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

Searching PubMed…

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.

Code example in Mallard: Kruskal-Wallis test with group medians (kruskal-wallis).
Calculators: Kruskal–Wallis (§3.2).
Atlas node 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.

Code for this method
Loading…

Work it out

Related Learn pages

Related designs and methods

Evidence

Sources & further reading

  1. 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
  2. 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
Prepared with AI assistance. PubMed metadata matched by title, authors, year and DOI on 2026-11-07. Record verified, confirm it supports this use. No independent professional approval is claimed. Kruskal and Wallis’s 1952 classic, Use of Ranks in One-Criterion Variance Analysis, was not found in PubMed by exact-title search. No PMID is assigned to it.
Last source review: 2026-11-07
AI-generated educational content
Mallard uses reputable methodological and reporting sources, but this material may contain errors or omit important context. Verify important methodological decisions with the cited sources and, when appropriate, a qualified research methodologist or statistician.