Statistics & Analysis

Kruskal Wallis Test

Reviewed byShrishti Chaudhary

Definition

The Kruskal Wallis test is a nonparametric statistical test used to determine whether there are statistically significant differences in the distributions (assessed through mean ranks; a difference can be read as a difference in medians only when the groups' distributions have the same shape and spread) of a continuous or ordinal dependent variable across three or more independent groups. It serves as the nonparametric alternative to one way analysis of variance (ANOVA) when the assumption of normality is not met.[1][2] It does not remove the need for similar spreads: unequal spreads across groups can themselves produce a significant result.

Explore the concept

Rank first, then compare

Turn 80 runners' exertion ratings into ranks, see how far the mean ranks sit apart as H, and find which protocols differ.

Perceived exertion, 20 runners per protocol

6912151820ABCDBorg ratingProtocol
ABCD

Skewed ratings on an ordinal scale

Ratings bunch up with a long tail, and a Shapiro Wilk test flags three of the four groups as not normal. That is the case for a rank based test instead of ANOVA.

The big idea: The Kruskal Wallis test ranks all observations together and asks whether the groups' mean ranks sit further apart than chance would allow. A significant H says at least one group differs; post hoc tests with a multiple comparison adjustment say which.

The design (four protocols, 20 runners each, Borg 6 to 20 scale), H(3) = 14.8, p = 0.002, normality failing in three groups and the Dunn results (D vs A adjusted p 0.003, D vs B 0.01, other pairs not significant) are the article's example. The 80 ratings are illustrative, built so that they reproduce those results: tie corrected H = 14.80, p = 0.0020; Dunn z tests with tie correction and Bonferroni adjustment for 6 pairs give D vs A 0.0029, D vs B 0.0099 and C vs D 0.21, the rest 1; Shapiro Wilk p below 0.05 in groups A, B and C. Mean ranks are from these illustrative data. 7.81 is the 95th percentile of chi squared with 3 df.

Why it matters

Many research datasets contain continuous or ordinal variables that are not normally distributed, particularly when sample sizes are small, when outcomes are measured on ordinal scales (such as Likert items), or when the data contain substantial outliers. Applying ANOVA to such data can produce misleading results because the test's validity depends on distributional assumptions. The Kruskal Wallis test provides a valid alternative that does not require normality and is resistant to the influence of outliers. It is widely used in clinical research, behavioral science, ecology, and any field where researchers need to compare three or more groups without relying on parametric assumptions.

How it works

The Kruskal Wallis test operates on the ranks of the data rather than the raw values. All observations from all groups are combined into a single sample and ranked from smallest to largest.[2][4] Tied values receive the average of the ranks they would have occupied.[2][4] The test statistic (H) is then calculated based on the sum of ranks within each group, adjusted for the overall mean rank. The formula is H = (12 divided by N(N+1)) times the sum across groups of (R_j squared divided by n_j) minus 3(N+1), where N is the total number of observations, R_j is the sum of ranks in group j, and n_j is the number of observations in group j.[2][4]

Under the null hypothesis (all groups are drawn from the same distribution), the test statistic H approximately follows a chi squared distribution with k minus 1 degrees of freedom, where k is the number of groups.[2][4] A significant result (p value below the chosen alpha) indicates that at least one group differs from the others, but it does not specify which groups differ or by how much.

To identify which specific groups differ, post hoc pairwise comparisons are conducted, for example with the Dunn test, which compares mean ranks from the combined ranking of all groups and divides alpha across the comparisons (a Bonferroni type correction).[3] The Steel Dwass and Conover tests are alternatives, and other corrections for multiple comparisons (such as Benjamini Hochberg adjustments) can be used. Effect size for the Kruskal Wallis test can be reported as eta squared based on H, calculated as (H minus k plus 1) divided by (N minus k), or as epsilon squared, calculated as H divided by ((N squared minus 1) divided by (N + 1)), which simplifies to H divided by (N minus 1); the rank biserial correlation is used for pairwise comparisons.

When to use it

Use the Kruskal Wallis test when comparing three or more independent groups on a continuous or ordinal dependent variable and when one or more of the following conditions apply: the data are not normally distributed (as assessed by Shapiro Wilk test, Q Q plots, or visual inspection), sample sizes are small and the central limit theorem cannot be relied upon, the dependent variable is measured on an ordinal scale rather than a true interval or ratio scale, or the data contain outliers that would unduly influence the ANOVA F test. If you have only two groups, use the Mann Whitney U test instead, which is the two group equivalent.[1][4]

Key takeaways

  • Many research datasets contain continuous or ordinal variables that are not normally distributed, particularly when sample sizes are small, when outcomes are measured on ordinal scales (such as Likert items), or when the data contain substantial outliers.
  • All observations from all groups are combined into a single sample and ranked from smallest to largest.
  • Use the Kruskal Wallis test when comparing three or more independent groups on a continuous or ordinal dependent variable and when one or more of the following conditions apply: the data are not normally distributed (as assessed by Shapiro Wilk test, Q Q plots, or visual inspection), sample sizes are small and the central limit theorem cannot be relied upon, the dependent variable is measured on an ordinal scale rather than a true interval or ratio scale, or the data contain outliers that would unduly influence the ANOVA F test.
  • A common error is using the Kruskal Wallis test without following up with post hoc comparisons after obtaining a significant result, leaving unanswered the question of which groups actually differ.

Common mistakes

  • A common error is using the Kruskal Wallis test without following up with post hoc comparisons after obtaining a significant result, leaving unanswered the question of which groups actually differ.
  • Another mistake is interpreting the Kruskal Wallis test as comparing medians: it tests whether values in some groups tend to be larger than in others (whether the mean ranks differ), and it compares medians only when the groups' distributions have the same shape and spread. If the distributions have different shapes or spreads across groups, a significant result may reflect differences in variability or skew rather than in medians.
  • Some researchers also fail to check whether the assumption of independent observations is met (the test does not handle repeated measures or clustered data).[4]
  • Finally, applying the test to very small groups (fewer than 5 observations per group) can reduce statistical power to unacceptable levels.

Example

A sports science researcher compares perceived exertion (measured on a 6 to 20 Borg scale) across four training protocols in 80 recreational runners (20 per group). A Shapiro Wilk test indicates significant departures from normality in three of the four groups. The Kruskal Wallis test yields H(3) = 14.8, p = 0.002, indicating significant differences among the groups. Post hoc Dunn tests with Bonferroni correction reveal that Protocol D produces significantly lower perceived exertion than both Protocol A (adjusted p = 0.003) and Protocol B (adjusted p = 0.01), while no other pairwise comparisons are significant.

Test your understanding

5 questions that adapt as you go: answer two in a row correctly and they get harder.

Question 1 of 5

Scenario:

A Kruskal Wallis test comparing exam anxiety ratings under three teaching methods gives H(2) = 9.2, p = 0.01.

Question:

What is the most accurate reading?

Hardness: Interpret

Sources

  1. [1]Field A. Discovering Statistics Using IBM SPSS Statistics. 6th ed. SAGE Publications, 2024. ISBN 9781529630008
  2. [2]Kruskal WH, Wallis WA. Use of ranks in one-criterion variance analysis. Journal of the American Statistical Association. 1952;47(260):583-621. doi:10.1080/01621459.1952.10483441
  3. [3]Dunn OJ. Multiple comparisons using rank sums. Technometrics. 1964;6(3):241-252. doi:10.1080/00401706.1964.10490181
  4. [4]Hollander M, Wolfe DA, Chicken E. Nonparametric Statistical Methods. 3rd ed. Wiley, 2014. ISBN 9780470387375

Cite this term

FullPaperguide. (2026, October 15). Kruskal Wallis Test. In Paperguide Research Glossary. https://paperguide.ai/research-glossary/kruskal-wallis-test/
In-text(Paperguide, 2026)

Related terms