- Introduced by
- William Kruskal & W. Allen Wallis
- Year
- 1952
- Type
- Nonparametric group comparison
What does it do?
The Kruskal-Wallis H test is a nonparametric hypothesis test that compares three or more independent groups to decide whether they come from the same population.
It was introduced by William Kruskal and W. Allen Wallis in 1952 and works on ranks rather than raw values. It is the rank-based counterpart to one-way ANOVA. A difference in medians is a valid reading only when the group distributions have similar shapes.
The intuition behind the method
Sometimes you have three or more separate groups measured on an ordinal or continuous outcome, but the data are skewed, ordinal, or otherwise too far from normal for ANOVA. Instead of comparing means, the test pools every observation, replaces each value by its rank, and asks whether some groups tend to hold systematically higher or lower ranks than others. If the groups were truly alike, the ranks would be scattered evenly across them.
History
The test was introduced by William Kruskal and W. Allen Wallis in their 1952 Journal of the American Statistical Association paper 'Use of ranks in one-criterion variance analysis'. It generalises the two-sample Mann-Whitney U test to several groups and serves as the nonparametric analogue of one-way ANOVA. The 1952 paper describes detecting differences among population means as one of the test's most important applications, and it supplies exact tables and special approximations for small samples.
When to use it
Use it to compare three or more independent groups on an outcome that is at least ordinal, when the normality assumption of one-way ANOVA is not credible. Each observation must belong to exactly one group and observations must be independent. To read the result as a comparison of medians, the groups should have similar distribution shapes. With very small groups the chi-square approximation is unreliable; use the exact tables or special approximations provided in the original paper, or exact or permutation-based p-values from software, which a researcher may consider as an alternative. No fixed minimum sample size is given in the original abstract, so check your software's documentation for the rule it applies. Do not use it for repeated measures on the same units; the Friedman test is the related alternative for that design.
Limitations and considerations
- It is an omnibus test: a significant result does not identify which groups differ without post-hoc testing.
- When group shapes or spreads differ, a significant result can arise even when the medians are equal, so it tests stochastic dominance rather than medians; inspect group distributions (e.g. box plots) before reporting.
- The chi-square reference distribution is an approximation and is unreliable when group sizes are small; the original paper provides exact tables for that case.
- Heavy ties make the uncorrected H conservative, so a tie correction is needed.
- When the data are genuinely normal it is generally less powerful than one-way ANOVA, because it discards the magnitudes of the values.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- Makes no normality assumption, so it can be applied to skewed or ordinal data where the normality requirement of one-way ANOVA is not met.
- Works on ranks, so an extreme value contributes only its rank rather than its full magnitude, which limits the influence of outliers compared with mean-based comparisons.
- Extends the two-group Mann-Whitney U logic naturally to three or more groups.
Applications
- Comparing an ordinal outcome (such as a Likert satisfaction rating) across three or more groups.
- Comparing a skewed continuous outcome across several treatment conditions when ANOVA assumptions fail.
- Comparing count or ranked performance data across multiple groups in survey and social-science research.
- Screening for group differences in biomedical or ecological studies with non-normal data of adequate size.
How it works
How it works
The null hypothesis states that all k groups are drawn from the same distribution. The alternative states that at least one group differs, i.e. is stochastically different. The test is primarily a test of whether the distributions differ. Reading a significant result as a difference in medians requires that the groups have similar shapes and spreads, which the analyst should check (for example with box plots).
Formula
H_0:\ \text{all } k \text{ groups share the same distribution} \quad H_1:\ \text{at least one group is stochastically different}All N observations from every group are pooled and ranked together, with tied values receiving the mean of the ranks they span. For each group the ranks are summed into Rᵢ, and the H statistic measures how far these rank sums depart from what equal groups would produce, scaled by the group sizes nᵢ. Larger separations between groups push H upward. The displayed formula is the form without ties. When ties are present, H should be divided by a tie-correction factor; software normally applies this automatically, and with many ties the uncorrected H is conservative. Under the null hypothesis H is approximately chi-square distributed with k − 1 degrees of freedom. The 1952 paper notes that this holds unless the samples are too small, in which case it provides special approximations or exact tables.
Formula
H = \dfrac{12}{N(N+1)} \sum_{i=1}^{k} \dfrac{R_i^2}{n_i} - 3(N+1)The null hypothesis is rejected when the p-value falls below the chosen significance level; 0.05 is a conventional choice, not a property of the test, and a small p-value alone does not establish how large or meaningful a difference is. If the test is repeated across several outcomes, adjust for multiplicity. Because the test is omnibus, it does not say which groups differ. Follow a significant result with post-hoc pairwise comparisons (Dunn's test with Bonferroni or Holm adjustment) and report a rank-based effect size such as epsilon-squared (ε²).
Formula
\text{reject } H_0 \text{ if } p < 0.05,\ \text{ where } H \sim \chi^2_{k-1}Common pitfalls
- Reading a significant H statistic as 'group A differs from group B' without running Dunn's post-hoc comparisons.
- Interpreting the result as a median comparison when the groups have clearly different distribution shapes or spreads.
- Applying the chi-square approximation to very small groups; use exact tables or exact/permutation p-values instead.
- Using a no-ties formula on data with many tied values without applying the tie correction.
Frequently asked questions
How is it different from one-way ANOVA?
One-way ANOVA compares group means and assumes the data are normally distributed with equal variances. The Kruskal-Wallis test compares the ranks of the values instead, so it makes no normality assumption and is the recommended choice when the data are ordinal, skewed, or contain outliers.
Does it compare medians or distributions?
Strictly, it tests whether the groups come from the same distribution. When the groups share a similar distribution shape, a significant result can be interpreted as a difference in medians; when the shapes differ, it indicates stochastic dominance rather than a clean median difference.
It is significant — which groups differ?
Kruskal-Wallis is an omnibus test, so it only tells you that at least one group differs. To locate the differences, run post-hoc pairwise comparisons such as Dunn's test with a Bonferroni or Holm correction, and report an effect size like epsilon-squared or eta-squared.
How large a sample do I need?
No fixed minimum is given here. With small groups the chi-square approximation becomes unreliable and the test loses power; in that situation a permutation test is a more dependable alternative.
Related methods
Sources
Kruskal, W. H. & Wallis, W. A. (1952). Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association, 47(260), 583–621.
Open DOI reference