Use the Kruskal-Wallis test when you want to compare three or more independent groups on a numeric or ranked outcome, but your data are not normally distributed or are measured on an ordinal scale — it's the nonparametric alternative to one-way ANOVA. If you ran a one-way ANOVA, saw a warning about non-normal residuals or a tiny sample, and now don't know what to do next, the Kruskal-Wallis test is almost certainly what you need.
Key Takeaways
- The Kruskal-Wallis test compares three or more independent groups and answers one question: do at least two of the groups differ on the outcome?
- It's the nonparametric version of one-way ANOVA — use it when your outcome is ordinal, skewed, has outliers, or fails the normality assumption.
- It works on ranks, not raw values, which is why it's robust to outliers and non-normal data.
- A significant Kruskal-Wallis result tells you that groups differ, not which ones — you need post-hoc tests (like Dunn's test) to find the specific differences.
- Report it in APA 7 as H(df) = value, p = value, with an effect size such as epsilon-squared (ε²).
What is the Kruskal-Wallis test?
The Kruskal-Wallis test (formally the Kruskal-Wallis H test) is a statistical test that checks whether three or more independent groups come from the same distribution, based on their ranked values rather than their raw scores. Think of it as one-way ANOVA's rank-based cousin: instead of comparing group means, it pools every observation, ranks them from smallest to largest, and then compares the average rank in each group.
Because it relies on ranks, the Kruskal-Wallis test doesn't care whether your data are normally distributed or have a few extreme outliers — a single billionaire in an income survey won't distort a rank the way it would distort a mean. That robustness is the whole reason it exists.
When should I use a Kruskal-Wallis test?
Use a Kruskal-Wallis test when all of these are true:
- You have one categorical independent variable with three or more groups (e.g., three teaching methods, four hospitals, five diet plans).
- Your groups are independent — different people in each group, not the same people measured repeatedly.
- Your outcome is continuous or ordinal (a test score, a pain rating, a Likert-scale item).
- Your data violate the assumptions of one-way ANOVA — the residuals aren't normal, you have serious outliers, sample sizes are small, or the outcome is genuinely ordinal.
If you only have two groups, use the Mann-Whitney U test instead. If your outcome is normally distributed with roughly equal variances, one-way ANOVA is more powerful — reach for that. And if the same participants appear in every condition (a repeated-measures design), you want the Friedman test, not Kruskal-Wallis.
Kruskal-Wallis vs one-way ANOVA: which do I need?
| Feature | Kruskal-Wallis | One-way ANOVA |
|---|---|---|
| Compares | 3+ independent groups | 3+ independent groups |
| Based on | Ranks | Means |
| Outcome type | Ordinal or continuous | Continuous |
| Normality required? | No | Yes (of residuals) |
| Handles outliers well? | Yes | No |
| Post-hoc test | Dunn's test | Tukey's HSD |
| Effect size | Epsilon-squared (ε²) or eta-squared (η²) | Eta-squared (η²) |
| Power when data are normal | Slightly lower | Higher |
The short version: if your data behave (normal, no wild outliers), ANOVA wins on power. If they don't, Kruskal-Wallis is the honest choice.
How does the Kruskal-Wallis test actually work?
The mechanics are more intuitive than the intimidating name suggests:
- Pool all observations from every group into one big list.
- Rank them from lowest (rank 1) to highest, ignoring which group they came from. Tied values get the average of the ranks they'd occupy.
- Sum the ranks within each group and compute each group's average rank.
- Calculate the H statistic, which measures how far the group average ranks are from what you'd expect if all groups were identical.
- Compare H to a chi-square distribution with degrees of freedom equal to (number of groups − 1) to get a p-value.
If groups are truly similar, their average ranks will be close together and H will be small. If one group clusters at the high end and another at the low end, H grows large and p shrinks.
A worked example with real numbers
Imagine a study of 30 patients testing whether three pain-relief treatments differ. Ten patients each rate their pain on a 0–10 scale (an ordinal outcome — perfect for Kruskal-Wallis):
- Group A (drug): median = 3
- Group B (physiotherapy): median = 5
- Group C (placebo): median = 7
We rank all 30 scores together, sum the ranks within each group, and compute the test statistic. Suppose the result is:
H(2) = 11.42, p = .003
Here's what each piece means:
- H = 11.42 — the test statistic; larger values mean the groups' average ranks are further apart.
- (2) — the degrees of freedom, calculated as 3 groups − 1 = 2.
- p = .003 — well below the conventional .05 threshold, so we reject the null hypothesis that all three treatments produce the same pain distribution.
We also report an effect size. Epsilon-squared here would be ε² = 0.39, indicating a large effect — the treatment groups explain a substantial share of the variation in pain ranks.
What does a significant result actually tell me?
A significant Kruskal-Wallis result tells you that at least two groups differ — but not which ones. To find out whether the drug beat the placebo, or physiotherapy beat the drug, you run a post-hoc test, most commonly Dunn's test, with a correction (Bonferroni or Holm) to control the false-positive rate across multiple comparisons. Without post-hoc testing, all you can honestly say is "the groups are not all the same."
How do I report the Kruskal-Wallis test in APA 7?
APA 7 formatting for a Kruskal-Wallis result looks like this:
A Kruskal-Wallis test showed a statistically significant difference in pain ratings across the three treatment groups, H(2) = 11.42, p = .003, ε² = 0.39. Dunn's post-hoc tests with Bonferroni correction indicated that placebo (Mdn = 7) produced significantly higher pain than the drug (Mdn = 3), p = .002.
Note the APA conventions: italicise H, p, and Mdn; drop the leading zero on p-values (.003, not 0.003); report degrees of freedom in parentheses; and always include an effect size and group medians so readers can judge the size of the difference, not just its existence.
Running it without the manual pain
Calculating ranks by hand for 30 patients is tedious; for 300 it's a nightmare, and one transcription error quietly invalidates your whole result. This is exactly where StatRyx earns its keep. StatRyx is an AI-powered statistical analysis tool that replaces manual SPSS workflows with automated, APA 7-formatted reporting — you upload your data, and it checks the ANOVA assumptions for you, recommends Kruskal-