Kruskal-Wallis Test Explained: How to Make, Read and Report It

By Dr. Faheem Afzal Shah, Founder, StatFAS.com · Tool: Kruskal-Wallis Test Calculator

The Kruskal-Wallis test compares three or more independent groups using ranks. It extends the Mann-Whitney U test and is the rank-based counterpart of one-way ANOVA.

What it tests

It tests whether at least one group tends to produce larger values than the others. It compares medians only when group distributions have similar shapes. Assumptions: independent observations, one grouping variable with three or more categories, and an ordinal or continuous outcome.

Calculation

H = [12 / (N(N + 1))] Σ (Rj2 / nj) − 3(N + 1)

Rj is the rank sum of group j, nj its size and N the total. H is compared with a χ² distribution with k − 1 degrees of freedom (a good approximation for adequate group sizes). A tie correction is applied when ties are present.

Original example (illustrative)

Recovery times (days) under three rehabilitation programmes, n = 4 each. A: 7, 9, 6, 8. B: 12, 10, 11, 13. C: 15, 14, 16, 17.

The groups do not overlap, so ranks are A = 1–4 (R = 10), B = 5–8 (R = 26), C = 9–12 (R = 42). Check: 10 + 26 + 42 = 78 = 12 × 13 / 2. Then H = (12/156) × (100/4 + 676/4 + 1764/4) − 39 = 0.0769 × 635 − 39 = 9.85. With df = 2, p = e−H/2 = .007. The epsilon-squared effect size is H/(N − 1) = 9.85/11 = .90 (Tomczak & Tomczak, 2014). Medians are 7.5, 11.5 and 15.5 days.

This example is deliberately extreme (no overlap). With four observations per group the chi-square approximation is rough, and an exact or permutation p-value would be preferable. Real data will rarely separate this cleanly.

Post hoc comparisons

A significant H only says that groups differ somewhere. Use Dunn's test (Dunn, 1964) or pairwise Mann-Whitney tests with a multiplicity adjustment (such as Holm or Bonferroni) to locate differences.

How to make it in StatFAS

Open the Kruskal-Wallis Test Calculator. Use a group column and an outcome column.

APA 7 reporting

A Kruskal-Wallis test showed a significant difference in recovery time among the three programmes, H(2) = 9.85, p = .007, ε² = .90.

Common mistakes and alternatives

Treating H as a test of medians without checking shapes, skipping post hoc correction, using it for repeated measures (use Friedman), and running many unadjusted Mann-Whitney tests. For normally distributed data see the ANOVA calculator.

Conclusion

Kruskal-Wallis is a robust choice for comparing several independent groups, provided you follow it with controlled pairwise comparisons.

Screenshots to supply (genuine captures only):
1. statfas-kruskal-wallis-test-interface.png, alt: "StatFAS Kruskal-Wallis Test Calculator interface"
2. statfas-kruskal-wallis-test-example-data.png, alt: "Example data entered in the StatFAS Kruskal-Wallis Test Calculator"
3. statfas-kruskal-wallis-test-settings.png, alt: "Kruskal-Wallis Test Calculator settings in StatFAS"
4. statfas-kruskal-wallis-test-result.png, alt: "Kruskal-Wallis Test Calculator result generated in StatFAS"

References