The Kruskal-Wallis Test

Info sheet · Statistics for Psychology & Neuroscience

Author

Andrew Bell

Published

August 13, 2026

Info sheet 0.2 (draft) · Prerequisites: one-way ANOVA; ranks; the idea of a non-parametric test · Give feedback ↗

Working notes for the author — not shown to students once collapsed; remove before publishing.

  • [ ]

What you’ll get from this sheet

The non‑parametric backup for when ANOVA’s assumptions fail. By the end you should be able to:

  1. Say what the Kruskal–Wallis test does and how it differs from ANOVA.
  2. Run one in R and report it in APA style.

The Kruskal–Wallis test is the non‑parametric equivalent of a one‑way independent ANOVA. It works on the ranks of the data, not the raw values, so it makes no distributional assumption. It returns an H statistic (compared to a χ² distribution) instead of an F.

Parametric vs non-parametric

A parametric test — a t‑test or ANOVA — assumes the data follow a particular distribution (usually normal), described by parameters (the mean and SD). A non‑parametric test makes no such assumption: it’s parameter‑free, working instead from the ranks (the ordering) of the data. Most standard tests have a non‑parametric partner — the Mann–Whitney (rank‑sum) test replaces the independent t‑test, the signed‑rank test replaces the paired t‑test — and the Kruskal–Wallis test replaces the one‑way independent ANOVA.

Where ANOVA compares variance between and within groups, Kruskal–Wallis compares each group’s rank sum to the grand mean rank. If one group holds mostly the low ranks and another mostly the high ranks, the groups likely differ. Its statistic is H (sometimes K), and it’s read off a χ² distribution with (groups − 1) degrees of freedom.

Ranks, not values

Fifteen data points across three groups. Drag one group apart and watch the raw values get ranked 1–15, the rank sums pull apart, and H climb.

The test never looks at the raw numbers again once they’re ranked — that’s what frees it from any distribution assumption. When the three groups overlap, each holds a fair mix of low and high ranks, the rank sums are similar, and H is small. Pull group C up and it hoards the top ranks; the rank sums diverge, and H grows past the χ²(2) critical value of 5.99.

See it in code

The syntax is identical to aov — just swap in kruskal.test, and note you don’t transform the data (that’s the whole point):

p = kruskalwallis(fans, origin);   % returns the KW table, H, and p

The R and Python tabs run live; MATLAB is a static reference.

Reporting it (APA)

Like ANOVA, Kruskal–Wallis is an omnibus test — it says country of origin mattered, not which country won. Report H (not F), with its degrees of freedom:

A Kruskal–Wallis test showed a significant effect of country of origin on the number of fans, H(3) = 18.2, p < .01.

You ran a Kruskal–Wallis test because your data were badly skewed, and it’s significant. A colleague suggests following up with pairwise t‑tests. Good idea?

No. You used Kruskal–Wallis precisely because you can’t assume normality, so parametric t‑tests are off the table for the follow‑ups too. Use non‑parametric pairwise comparisons instead — Mann–Whitney (rank‑sum) tests between pairs (with a multiple‑comparison correction), or Dunn’s test. And, as always, only follow up a significant omnibus result.

Kruskal–Wallis makes no distributional assumption, so there are no normality/variance tests to run — but it isn’t assumption‑free: it still needs independent observations, and it’s a test of whether the groups’ distributions differ (often read as a difference in medians only when the group distributions have similar shapes). And because it throws away the raw magnitudes in favour of ranks, it’s a little less powerful than ANOVA when ANOVA’s assumptions genuinely hold — so don’t reach for it by default.

Where this shows up next

This is the fallback whenever the ANOVA assumptions fail. See Chapter (ANOVA), and the When Data Aren’t Normal sheet for the transform‑vs‑non‑parametric decision.