Kruskal-Wallis Test Calculator
Test whether 3 or more independent groups differ in their distributions. Non-parametric alternative to one-way ANOVA.
§1How this was calculated
§2The formula
- H
- Kruskal-Wallis test statistic
- N
- Total sample size across all groups
- k
- Number of groups
- nᵢ
- Sample size of group i
- Rᵢ
- Sum of ranks in group i
Tie correction
When ties (identical values) exist:
- Hc
- Corrected H statistic
- T
- t³ − t for each tie group of size t
- ΣT
- Sum of T across all tie groups
The corrected H statistic is compared to a χ² distribution with df = k − 1.
§3Worked example
Three groups, n = 4 each:
| Group 1 | Group 2 | Group 3 |
|---|---|---|
| 3 | 5 | 8 |
| 4 | 6 | 9 |
| 4 | 7 | 10 |
| 5 | 8 | 11 |
Combined and ranked: 3(1), 4(2.5), 4(2.5), 5(4.5), 5(4.5), 6(6), 7(7), 8(8.5), 8(8.5), 9(10), 10(11), 11(12). Notice that 4 and 5 each appear twice; these receive average ranks.
Rank sums: R₁ = 1 + 2.5 + 2.5 + 4.5 = 10.5; R₂ = 4.5 + 6 + 7 + 8.5 = 26; R₃ = 8.5 + 10 + 11 + 12 = 41.5
Tie count: Two ties (one at value 4, one at value 5), each size 2, so T = 2³ − 2 + 2³ − 2 = 6 + 6 = 12.
H calculation:
H = (12 / (12 × 13)) × (10.5² / 4 + 26² / 4 + 41.5² / 4) − 3 × 13
= (12 / 156) × (27.56 + 169 + 430.56) − 39
= 0.0769 × 627.12 − 39
= 48.24 − 39
= 9.24
Tie correction: Hc = 9.24 / (1 − 12 / (1728 − 12)) = 9.24 / (1 − 12/1716) = 9.24 / 0.993 ≈ 9.30
df = 3 − 1 = 2. Comparing H ≈ 9.30 to χ²(2), p ≈ 0.0099. Since p < 0.05, we reject H₀ at α = 0.05.
§4Assumptions & when this test is wrong
When to use
- Three or more independent groups.
- Your dependent variable is ordinal or continuous but the data is skewed, have outliers, or violate normality.
- Sample sizes can be unequal.
When not to use
- Only two groups — use Mann-Whitney U test instead.
- Data are paired or repeated measures — use Friedman's test instead.
- Normality is assured — one-way ANOVA may have more power.
What this test does and does not tell you
The Kruskal-Wallis test answers: "Do these groups differ in their distributions?" A significant result means at least one group differs from the others, but does not tell you which pairs differ. To identify specific differences, use a post-hoc test such as Dunn's test (which applies pairwise Mann-Whitney comparisons with adjusted α to control family-wise error). This calculator shows only the omnibus test; post-hoc pairwise comparisons are beyond its scope.
§5Frequently asked questions
What does a tie correction do?
When multiple observations have the same value, they receive average ranks. This reduces variance in the rank sums, which can inflate the test statistic. The tie correction adjusts H downward slightly when ties are present, yielding a more conservative p-value and reducing false positives.
Why is this test "non-parametric"?
It does not assume the data come from a normal distribution; instead, it ranks the data and compares rank sums. This makes it robust to outliers and skewness. The trade-off is that it is slightly less sensitive (less statistical power) than ANOVA if data truly are normal.
Can I use this test for paired data?
No. Kruskal-Wallis assumes independent groups. For matched or repeated measures, use Friedman's test (the non-parametric counterpart to repeated-measures ANOVA).
What is a p-value?
The p-value is the probability of observing a test statistic this large if the null hypothesis were true (i.e., if all group distributions were identical). Small p-values (typically p < 0.05) suggest the groups differ; we reject H₀. A p-value is not the probability that H₀ is true.
How do I interpret a non-significant result?
If p ≥ 0.05, you fail to reject H₀ at α = 0.05. This does not prove the groups are identical; it means you lack sufficient evidence to conclude they differ. With small sample sizes, real effects may go undetected. Always report sample sizes and effect sizes alongside p-values.
How do I report this result?
In APA style: "A Kruskal-Wallis test indicated that the three groups differed significantly, H(2) = 9.30, p = 0.0099." Report the H statistic, the df in parentheses, and the exact p-value.
§6Sources
- NIST/SEMATECH e-Handbook of Statistical Methods — Kruskal-Wallis Test section
- UCLA Online Archive of Research Computing — non-parametric methods
- Conover, W. J. (1999). Practical Nonparametric Statistics (3rd ed.). Wiley. ISBN 978-0471160458.