Skip to content
K Knidox Search…
Statistics · Nonparametric

Kruskal-Wallis Test

Compare three or more independent groups by rank — H, degrees of freedom, p, and effect size.

One group per line, values separated by commas or spaces. Groups may differ in size.
Kruskal-Wallis H
12.5Hp < .05

3 groups, N = 15, df = 2. Two or more groups differ if p is below your alpha.

p-value
0.0019

From the chi-square distribution with 2 degrees of freedom.

Effect size (ε²)
0.893

Epsilon-squared — the proportion of rank variance explained by group membership.

Kruskal-Wallis extends the Mann-Whitney test to three or more groups. For three groups of five with rank sums 15, 40 and 65, H = 12.50 with 2 degrees of freedom, giving p = .002 — at least two groups differ.

Nonparametric one-way ANOVA

One-way ANOVA compares group means and assumes the data are normal with similar variances. The Kruskal-Wallis test asks the same broad question — do these groups differ? — using only the ranks of the observations, which makes it suitable for skewed data, ordinal outcomes, and small samples.

All observations are pooled and ranked together. If the groups come from the same distribution, each group’s rank sum should be proportional to its size. H measures how far the observed rank sums stray from that expectation, and follows a chi-square distribution with k − 1 degrees of freedom when the null hypothesis is true.

What a significant H does and does not say

A significant result means at least one group differs from at least one other. It does not say which, nor how many — exactly like a significant F in ANOVA. Identifying the specific pairs needs a post-hoc procedure such as Dunn’s test with a correction for multiple comparisons.

H = (12 ÷ (N(N + 1))) × Σ (Rⱼ² ÷ nⱼ) − 3(N + 1) Tie-corrected: H ÷ (1 − Σ(t³ − t) ÷ (N³ − N)) df = k − 1

N is the total sample size, k the number of groups, Rⱼ the rank sum of group j, nⱼ its size, and t the size of each group of tied values.

Worked example: three groups of five

Rank across all fifteen values, then compare the rank sums:

  1. 1
    Pool and rank every value. All 15 observations are ranked together from 1 to 15, with ties sharing an average rank.
  2. 2
    Sum the ranks within each group. The groups separate cleanly here: R₁ = 15, R₂ = 40, R₃ = 65.
  3. 3
    Compute the weighted sum. 15² ÷ 5 + 40² ÷ 5 + 65² ÷ 5 = 45 + 320 + 845 = 1210.
  4. 4
    Apply the formula. 12 ÷ (15 × 16) × 1210 − 3 × 16 = 0.05 × 1210 − 48 = 60.5 − 48 = 12.50.
  5. 5
    Find the p-value. With df = 3 − 1 = 2, a chi-square of 12.50 gives p = .002.
  6. 6
    Follow up. The test says the groups differ; a post-hoc test such as Dunn’s identifies which pairs.

Choosing a test for three or more groups

The nonparametric route trades a little power under normality for robustness when it fails.

DesignParametricNonparametric
Three or more independent groupsOne-way ANOVAKruskal-Wallis H
Three or more repeated measuresRepeated-measures ANOVAFriedman test
Two independent groupsIndependent t-testMann-Whitney U
Two paired measurementsPaired t-testWilcoxon signed-rank
Follow-up comparisonsTukey HSDDunn’s test

Assumptions, ties, and small groups

Kruskal-Wallis assumes independent observations and that the groups have similarly shaped distributions. Under that condition a significant result can be read as a difference in medians; without it, the conclusion is the weaker but still useful one that the distributions differ.

Ties reduce the variability of the ranks, so H is divided by a correction factor. With coarse scales — a seven-point questionnaire item across a hundred respondents — the correction can change H noticeably, and this calculator applies it automatically.

The chi-square approximation assumes roughly five or more observations per group. With smaller groups, use an exact test rather than the approximate p-value. For reporting, give H, the degrees of freedom, N, the exact p, and an effect size such as epsilon-squared, along with medians and interquartile ranges per group.

What does a significant H tell me?
That at least one group differs from at least one other — nothing about which pairs. A post-hoc procedure such as Dunn’s test, with a correction for multiple comparisons, is needed to locate the differences.
When should I use it instead of ANOVA?
When the data are ordinal, the distributions are clearly skewed, or the groups are too small to check normality. ANOVA is slightly more powerful when its assumptions hold.
Does it compare medians?
Only when the groups have similarly shaped distributions. Otherwise it tests whether the distributions differ in general, which is a weaker but still meaningful conclusion.
Do the groups need to be equal in size?
No. The formula divides each group’s squared rank sum by that group’s own size, so unequal groups are handled directly.
How are ties handled?
Tied values share an average rank, and H is divided by a correction factor that accounts for how many ties occurred. The correction matters most on coarse scales where ties are frequent.
How small is too small?
The chi-square approximation assumes about five or more observations per group. Below that the p-value here becomes unreliable and an exact test is the better option.
What effect size should I report?
Epsilon-squared, computed from H and the sample size, is the common choice and is read as the proportion of rank variance explained by group membership. Eta-squared for H is also seen in the literature.