Nonparametric Tests Hypothesis Testing Statistical Tests 32 min read August 4, 2026
BY: Statistics Fundamentals Team
Reviewed By: Minsa A (Senior Statistics Editor)

Kruskal-Wallis Test: Real-Life Examples

A school researcher wants to compare exam scores across three teaching methods, but the scores are skewed. A clinician records patient recovery times under three treatments, but the data contains outliers. A farm trial measures crop yields for four fertilizer types across small plots. In each case, the Kruskal-Wallis test is the right tool: a nonparametric method that compares three or more groups without requiring normally distributed data.

This page covers eight fully solved examples spanning education, medicine, psychology, agriculture, marketing, and business — each with a complete ranking table, H statistic calculation, p-value, and Dunn's post hoc analysis where applicable. An interactive calculator lets you run the test on your own data.

What You'll Learn
  • ✓ The definition, assumptions, and formula for the Kruskal-Wallis test
  • ✓ A complete 7-step procedure with the tie-correction factor
  • ✓ Eight fully worked real-life examples with ranking tables and calculations
  • ✓ Dunn's post hoc test with Bonferroni correction, step by step
  • ✓ Comparison tables: Kruskal-Wallis vs ANOVA, Mann-Whitney U, and Friedman
  • ✓ Common mistakes, effect size, and how to report results in APA style
  • ✓ An interactive calculator — enter your own groups and get H, p-value, and decision

What Is the Kruskal-Wallis Test?

Definition — Kruskal-Wallis Test
The Kruskal-Wallis test is a nonparametric one-way analysis of variance based on ranks. It tests whether three or more independent groups come from populations with the same median, without assuming that the data is normally distributed. All observations are pooled and ranked together; the test statistic H measures whether the rank sums across groups differ more than chance would predict.
H₀: The population medians of all k groups are equal

William Kruskal and W. Allen Wallis published the test in the Journal of the American Statistical Association in 1952. They built on Frank Wilcoxon's rank-sum idea and extended it to more than two groups. The test ranks every observation from 1 (smallest) to N (largest) across all groups combined. If the group medians were truly equal, you would expect the ranks to be spread evenly across the groups. When they are not, the H statistic grows large, and the p-value falls below the significance threshold.

The H statistic follows approximately a chi-square (χ²) distribution with df = k − 1, where k is the number of groups. This approximation works well when each group has at least five observations. For smaller samples, exact critical values from special Kruskal-Wallis tables should be used. The full framework for parametric vs nonparametric tests is covered in the Statistics Fundamentals guide to hypothesis testing.

3+
Independent Groups Required
k−1
Degrees of Freedom
χ²
Reference Distribution
No
Normality Required
⚡ Quick Reference — Kruskal-Wallis Key Facts
  • Also called: Kruskal-Wallis H test, nonparametric one-way ANOVA, rank-based ANOVA
  • What it tests: Whether at least one group has a different median from the others
  • When to use it: Three or more independent groups, ordinal or continuous outcome, normality not met or unverifiable
  • Test statistic: H, which approximates χ² with df = k − 1
  • Decision rule: Reject H0 if H > χ2(α, df) or equivalently if p-value < α.
  • Post hoc test: Dunn's test with Bonferroni correction for pairwise comparisons
  • Parametric equivalent: One-Way ANOVA

Assumptions of the Kruskal-Wallis Test

The Kruskal-Wallis test has four assumptions. These are considerably less restrictive than those of one-way ANOVA, which is why researchers reach for it when ANOVA assumptions cannot be met.

1

Independence

Observations must be independent — both within each group and between groups. Each subject or data point belongs to exactly one group. Repeated measures or matched data violate this assumption; use the Friedman test instead.

2

Ordinal or Continuous Outcome

The dependent variable must be at minimum ordinal — it must be meaningful to say one value is "greater than" another. The test works with continuous measurements and with ranked or Likert-scale data. It cannot be used with purely nominal outcomes (e.g., categories without order).

3

Three or More Independent Groups

There must be one independent variable with at least three categories. For exactly two groups, use the Mann-Whitney U test, which is the two-group nonparametric equivalent.

4

Similar Distribution Shapes

For the Kruskal-Wallis test to compare medians specifically, the distribution shapes across groups should be similar (even if not normal). If the shapes differ markedly, the test compares mean ranks rather than medians, and the interpretation changes accordingly.

⚠️
Note: No Normality Assumption

Unlike one-way ANOVA, the Kruskal-Wallis test does not assume normally distributed residuals or equal variances (homoscedasticity). This makes it appropriate for skewed data, ordinal scales, and small samples where normality cannot be verified. See normality tests for guidance on when to switch from ANOVA to Kruskal-Wallis.

The H Statistic Formula

The Kruskal-Wallis H statistic is calculated from the rank sums of each group. The formula has two parts: the base H formula and an optional tie-correction factor applied when tied ranks are present.

Kruskal-Wallis H Statistic
H = [12 / (N(N+1))] × Σ[Rᵢ² / nᵢ] − 3(N+1)
N = total number of observations across all groups k = number of groups nᵢ = sample size of group i Rᵢ = sum of ranks for group i

Tie-Correction Factor

When two or more observations have the same value, they receive the same average rank (e.g., two values tied for ranks 4 and 5 both get rank 4.5). Ties slightly reduce the value of H. The tie-corrected H is:

Tie-Corrected H
Hcorrected = H / C
C = 1 − [Σ(t³ − t)] / (N³ − N)
t = number of observations in each tied group C = correction factor (always ≤ 1)

In practice, ties are common in real data and the correction matters most when ties are numerous. Statistical software (R, SPSS, SAS, Python's SciPy) applies this correction automatically. When calculating by hand, apply it whenever you have three or more tied values in a group.

Formula source: Kruskal, W.H. and Wallis, W.A. (1952). "Use of ranks in one-criterion variance analysis." Journal of the American Statistical Association, 47(260), 583–621. Available via JSTOR.

The 7-Step Procedure

📋
Featured Snippet — 7-Step Kruskal-Wallis Procedure

Step 1: State H₀ and H₁. Step 2: Check the four assumptions. Step 3: Rank all observations (1 to N). Step 4: Sum the ranks per group (R₁, R₂, …). Step 5: Calculate H (and apply tie correction if needed). Step 6: Find the p-value from the χ² distribution with df = k − 1. Step 7: If p < α, run Dunn's post hoc test.

1

State the Hypotheses

H₀: The population medians of all groups are equal. H₁: At least one group has a different median. You do not specify which group differs — that is for the post hoc test to determine.

2

Verify the Assumptions

Confirm independence, ordinal/continuous data, three or more groups, and similar distribution shapes. If the data has repeated measures, switch to the Friedman test. Review the full statistical assumptions guide if needed.

3

Pool and Rank All Observations

Combine every observation from all groups into one list. Rank them 1 to N from smallest to largest. For tied values, assign the mean of the ranks they would have occupied. Keep track of which original group each rank belongs to.

4

Calculate Group Rank Sums

Add up the ranks assigned to each group separately. Call these R₁, R₂, … Rk. As a check: R₁ + R₂ + … + Rk must equal N(N+1)/2.

5

Compute the H Statistic

Apply the H formula using N, k, the group sizes nᵢ, and the rank sums Rᵢ. If ties exist, divide H by the correction factor C to get the adjusted H.

6

Find the p-value and Make a Decision

Compare H to the chi-square distribution with df = k − 1 using a chi-square table. If H exceeds the critical value, or if p < α (typically 0.05), reject H₀. If p ≥ α, fail to reject H₀.

7

Post Hoc Analysis — Dunn's Test

A significant Kruskal-Wallis result only tells you that at least one group differs. Run Dunn's test to determine exactly which pairs differ, with Bonferroni-corrected p-values for each comparison.

Kruskal-Wallis Test Examples — 8 Fully Solved

All eight examples below follow the same 7-step structure. Data is original and chosen to reflect realistic distributions researchers encounter in practice. Calculations are shown in full. Where an example produces a significant result, Dunn's post hoc analysis is included.

Example 1 — Teaching Methods and Exam Scores (Education)

Worked Example 1 — Education Research

Scenario: A college instructor tests three teaching methods — lecture only (Group A), lecture + discussion (Group B), and flipped classroom (Group C). Fifteen students are randomly assigned (5 per group). End-of-term exam scores (out of 100) are recorded. Normality tests on these small samples are inconclusive, so the Kruskal-Wallis test is used. α = 0.05.

StudentGroup A (Lecture)Group B (Discussion)Group C (Flipped)
1587281
2626885
3557579
4607088
5576683
1

Hypotheses: H₀: Median exam scores are equal across all three teaching methods. H₁: At least one teaching method produces a different median exam score.

2

Assumptions: 15 independent students, one each per group, exam scores are continuous, three groups — all met. No repeated measures.

3

Rank all 15 observations (smallest to largest):

ScoreGroupRank
55A1
57A2
58A3
60A4
62A5
66B6
68B7
70B8
72B9
75B10
79C11
81C12
83C13
85C14
88C15
4

Group rank sums:
R_A = 1+2+3+4+5 = 15
R_B = 6+7+8+9+10 = 40
R_C = 11+12+13+14+15 = 65
Check: 15+40+65 = 120 = 15×16/2 ✓

5

Calculate H:
N = 15, n_A = n_B = n_C = 5
H = [12/(15×16)] × [(15²/5) + (40²/5) + (65²/5)] − 3×16
H = [12/240] × [45 + 320 + 845] − 48
H = 0.05 × 1210 − 48 = 60.5 − 48 = H = 12.5
No ties, so no correction needed.

6

p-value: df = k−1 = 2. From the chi-square table, χ²(0.05, 2) = 5.991. Since H = 12.5 > 5.991, we reject H₀. p ≈ 0.002.

7

Dunn's post hoc test: With Bonferroni correction (3 pairs, α_adjusted = 0.05/3 = 0.0167), all three pairwise comparisons are significant: A vs B (p ≈ 0.019*), A vs C (p < 0.001), B vs C (p ≈ 0.008). The flipped classroom significantly outperforms both other methods.

✅ Conclusion: H(2) = 12.5, p = 0.002. The teaching method has a statistically significant effect on exam scores. Post hoc analysis confirms all three methods differ from each other, with the flipped classroom producing the highest scores (Mdn = 83) and the lecture-only method the lowest (Mdn = 60).

Note on reporting: APA 7th edition recommends reporting as H(df) = value, p = value. Effect size (η²_H = (H − k + 1)/(N − k)) should also be reported: η²_H = (12.5 − 3 + 1)/(15 − 3) = 10.5/12 ≈ 0.875 (large effect by Cohen's 1988 benchmarks).

Example 2 — Patient Recovery Times (Medicine)

Worked Example 2 — Clinical Research

Scenario: A clinical trial tests three treatments for a knee injury: physical therapy alone (T1), physical therapy + ice (T2), and physical therapy + ultrasound (T3). Twelve patients are randomly assigned (4 per group). Days to full recovery are recorded. The distribution is right-skewed (some patients recover much later), making ANOVA inappropriate. α = 0.05.

PatientT1 (PT only)T2 (PT + Ice)T3 (PT + US)
121149
2281812
3351610
4422015
1

Hypotheses: H₀: Median recovery time is equal across T1, T2, and T3. H₁: At least one treatment produces a different median recovery time.

3

Rank all 12 observations:

DaysGroupRank
9T31
10T32
12T33
14T24
15T35
16T26
18T27
20T28
21T19
28T110
35T111
42T112
4

Group rank sums:
R_T1 = 9+10+11+12 = 42
R_T2 = 4+6+7+8 = 25
R_T3 = 1+2+3+5 = 11
Check: 42+25+11 = 78 = 12×13/2 ✓

5

Calculate H:
N = 12, n = 4 per group
H = [12/(12×13)] × [(42²/4) + (25²/4) + (11²/4)] − 3×13
H = [12/156] × [441 + 156.25 + 30.25] − 39
H = 0.0769 × 627.5 − 39 = 48.25 − 39 = H = 9.25

6

Decision: df = 2, χ²(0.05, 2) = 5.991. H = 9.25 > 5.991. p ≈ 0.010. Reject H₀.

✅ Conclusion: H(2) = 9.25, p = 0.010. The treatment type significantly affects recovery time. The ultrasound group recovered fastest (Mdn = 11 days), followed by the ice group (Mdn = 17 days), with physical therapy alone the slowest (Mdn = 31.5 days).

Example 3 — Customer Satisfaction Across Stores (Business)

Worked Example 3 — Customer Research

Scenario: A retail chain surveys customer satisfaction on a 1–10 Likert scale across four store locations (A, B, C, D). Likert data is ordinal, so the Kruskal-Wallis test is used rather than ANOVA. Four customers rated each store (n = 4 per group, N = 16). α = 0.05.

CustomerStore AStore BStore CStore D
15794
26883
357105
46994
1

Hypotheses: H₀: Median satisfaction is equal across all four stores. H₁: At least one store has a different median satisfaction rating.

3

Rank all 16 observations (with ties shown):

RatingStoreRank (tied = avg)
3D1
4D2.5
4D2.5
5A5
5A5
5D5
6A7.5
6A7.5
7B9.5
7B9.5
8B11.5
8C11.5
9B14
9C14
9C14
10C16
4

Group rank sums:
R_A = 5+5+7.5+7.5 = 25
R_B = 9.5+9.5+11.5+14 = 44.5
R_C = 11.5+14+14+16 = 55.5
R_D = 1+2.5+2.5+5 = 11
Check: 25+44.5+55.5+11 = 136 = 16×17/2 ✓

5

Calculate H (before tie correction):
H = [12/(16×17)] × [(25²/4)+(44.5²/4)+(55.5²/4)+(11²/4)] − 3×17
H = [12/272] × [156.25+495.0625+770.0625+30.25] − 51
H = 0.04412 × 1451.625 − 51 = 64.07 − 51 = H ≈ 13.07

Tie correction: Ties: (3 ties for 5; 2 ties for 4; 2 ties for 6; 2 ties for 7; 2 ties for 8; 3 ties for 9)
C = 1 − [Σ(t³−t)]/(N³−N) = 1 − [(27−3)+(8−2)+(8−2)+(8−2)+(8−2)+(27−3)]/(4096−16)
C = 1 − [24+6+6+6+6+24]/4080 = 1 − 72/4080 = 1 − 0.01765 = 0.9824
H_corrected = 13.07/0.9824 ≈ 13.31

6

Decision: df = 3, χ²(0.05, 3) = 7.815. H = 13.31 > 7.815. p ≈ 0.004. Reject H₀.

✅ Conclusion: H(3) = 13.31, p = 0.004. Customer satisfaction differs significantly across stores. Store C has the highest median satisfaction (9.0), Store D the lowest (4.0). Post hoc comparisons show C vs D and B vs D are the strongest contrasts.

Example 4 — Crop Yields with Four Fertilizers (Agriculture)

Worked Example 4 — Agricultural Research

Scenario: An agronomist tests four fertilizer types (Control, Nitrogen-only, NPK blend, Organic) on wheat yield (kg per plot) across 5 plots each (N = 20). Yields are skewed due to two plots experiencing drought conditions in one group. α = 0.05.

PlotControlN-onlyNPKOrganic
132415538
228456042
335395836
430435240
522475744
3

Ranks (pooled, 1–20):
Sorted values: 22(1), 28(2), 30(3), 32(4), 35(5), 36(6), 38(7), 39(8), 40(9), 41(10), 42(11), 43(12), 44(13), 45(14), 47(15), 52(16), 55(17), 57(18), 58(19), 60(20)

4

Group rank sums:
Control (22,28,30,32,35): R = 1+2+3+4+5 = 15
N-only (39,41,43,45,47): R = 8+10+12+14+15 = 59
NPK (52,55,57,58,60): R = 16+17+18+19+20 = 90
Organic (36,38,40,42,44): R = 6+7+9+11+13 = 46
Check: 15+59+90+46 = 210 = 20×21/2 ✓

5

Calculate H:
H = [12/(20×21)] × [(15²/5)+(59²/5)+(90²/5)+(46²/5)] − 3×21
H = [12/420] × [45+696.2+1620+423.2] − 63
H = 0.02857 × 2784.4 − 63 = 79.55 − 63 = H = 16.55

6

Decision: df = 3, χ²(0.05, 3) = 7.815. H = 16.55 > 7.815. p ≈ 0.001. Reject H₀.

✅ Conclusion: H(3) = 16.55, p = 0.001. Fertilizer type has a significant effect on wheat yield. The NPK blend produced the highest yields (Mdn = 57 kg), the control group the lowest (Mdn = 30 kg). Dunn's test confirms NPK differs from all other groups (p < 0.05 for all three comparisons after Bonferroni correction).

Example 5 — Employee Productivity by Department (Business/HR)

Worked Example 5 — Human Resources

Scenario: An HR manager records the monthly tasks completed by employees in three departments (Sales, Operations, and R&D), with 5 employees in each department. Because the distributions across departments differ in skewness, the Kruskal-Wallis test is preferred over one-way ANOVA. Use a significance level of α = 0.05.

Employee Sales Operations R&D
1486234
2555830
3516538
4607033
5456636
3

Rank all 15 values (sorted):
30(1), 33(2), 34(3), 36(4), 38(5), 45(6), 48(7), 51(8), 55(9), 58(10), 60(11), 62(12), 65(13), 66(14), 70(15)

4

Group rank sums:
Sales (48, 55, 51, 60, 45): Ranks 7, 9, 8, 11, 6 → RSales = 41
Operations (62, 58, 65, 70, 66): Ranks 12, 10, 13, 15, 14 → ROps = 64
R&D (34, 30, 38, 33, 36): Ranks 3, 1, 5, 2, 4 → RRD = 15
Check: 41 + 64 + 15 = 120 = 15 × 16 / 2 ✓

5

Calculate H:
H = [12/(15×16)] × [(41²/5)+(64²/5)+(15²/5)] − 3×16
H = [12/240] × [336.2+819.2+45] − 48
H = 0.05 × 1200.4 − 48 = 60.02 − 48 = H = 12.02

6

Decision: df = 2, χ²(0.05, 2) = 5.991. H = 12.02 > 5.991. p ≈ 0.002. Reject H₀.

Conclusion: H(2) = 12.02, p = 0.002. Productivity differs significantly across departments. Operations has the highest median task completion (64 tasks), while R&D has the lowest (34 tasks). Post hoc analysis indicates that the largest difference is between Operations and R&D.

Example 6 — Hospital Waiting Times (Healthcare)

Worked Example 6 — Healthcare Administration

Scenario: A hospital quality team records patient waiting times (minutes) at three emergency department triage categories: minor injuries, moderate injuries, and severe injuries. Five patients in each category. The team suspects right-skewed waiting times (some very long waits). α = 0.05.

PatientMinorModerateSevere
192458
2110525
3856012
4130486
5955510
3

Ranks (sorted from lowest to highest wait time):
5(1), 6(2), 8(3), 10(4), 12(5), 45(6), 48(7), 52(8), 55(9), 60(10), 85(11), 92(12), 95(13), 110(14), 130(15)

4

Group rank sums:
Severe: 1+2+3+4+5 = 15
Moderate: 6+7+8+9+10 = 40
Minor: 11+12+13+14+15 = 65
Check: 15+40+65 = 120 ✓

5

H = 12.5 (same rank structure as Example 1, confirming formula)

6

Decision: H = 12.5 > χ²(0.05, 2) = 5.991. p ≈ 0.002. Reject H₀.

✅ Conclusion: H(2) = 12.5, p = 0.002. Waiting time differs significantly by triage category. Severe cases are seen fastest (Mdn = 8 min) and minor cases wait longest (Mdn = 95 min), consistent with a correctly functioning triage system.

Example 7 — Stress Scores Across Three Professions (Psychology)

Worked Example 7 — Psychology Research

Scenario: A researcher measures occupational stress (Perceived Stress Scale, 0–40 score, higher = more stressed) in three professional groups: teachers (n=5), nurses (n=5), and software engineers (n=5). The PSS is an ordinal-leaning scale with a non-normal distribution in this sample. α = 0.05.

ParticipantTeachersNursesEngineers
1283518
2243222
3303815
4263020
5273619
3

Ranks (sorted):
15(1), 18(2), 19(3), 20(4), 22(5), 24(6), 26(7), 27(8), 28(9), 30(10.5), 30(10.5), 32(12), 35(13), 36(14), 38(15)
Note: Two scores of 30 — one from Teachers, one from Nurses — both get rank (10+11)/2 = 10.5

4

Group rank sums:
Teachers (28,24,30,26,27): Ranks 9,6,10.5,7,8 → R_T = 40.5
Nurses (35,32,38,30,36): Ranks 13,12,15,10.5,14 → R_N = 64.5
Engineers (18,22,15,20,19): Ranks 2,5,1,4,3 → R_E = 15
Check: 40.5+64.5+15 = 120 ✓

5

H (uncorrected):
H = [12/(15×16)] × [(40.5²/5)+(64.5²/5)+(15²/5)] − 3×16
H = 0.05 × [328.05+832.05+45] − 48 = 0.05×1205.1 − 48 = 60.255 − 48 = 12.255

Tie correction: One pair of ties (t=2): Σ(t³−t) = (8−2) = 6
C = 1 − 6/(3375−15) = 1 − 6/3360 = 0.9982
H_corrected = 12.255/0.9982 ≈ 12.277

6

Decision: H = 12.28 > χ²(0.05, 2) = 5.991. p ≈ 0.002. Reject H₀.

✅ Conclusion: H(2) = 12.28, p = 0.002. Occupational stress differs significantly across professions. Nurses report the highest median stress (Mdn = 35), engineers the lowest (Mdn = 19). Post hoc Dunn's test: Nurses vs Engineers (p < 0.001), Teachers vs Engineers (p = 0.007), Nurses vs Teachers (p = 0.031) — all significant after Bonferroni correction.

Example 8 — Marketing Campaign Conversion Rates (Business)

Worked Example 8 — Marketing Analytics

Scenario: A digital marketing team runs three email campaign types (Standard newsletter, Personalized offer, Flash sale) across 6 audience segments each. Conversion rates (%) per segment are recorded. The distribution is skewed, with a few very high-converting segments. α = 0.05.

SegmentNewsletterPersonalizedFlash Sale
11.23.85.1
22.14.26.3
31.83.54.9
42.54.87.2
51.53.15.8
62.04.06.0
1

Hypotheses: H₀: Median conversion rate is equal across the three campaign types. H₁: At least one campaign type produces a different median conversion rate.

3

Ranks (1–18 from lowest to highest conversion rate):
Newsletter values get ranks 1–6, Personalized get ranks 7–12, Flash Sale get ranks 13–18 (no overlaps between groups in this dataset)

4

Group rank sums:
R_Newsletter = 1+2+3+4+5+6 = 21
R_Personalized = 7+8+9+10+11+12 = 57
R_Flash = 13+14+15+16+17+18 = 93
Check: 21+57+93 = 171 = 18×19/2 ✓

5

Calculate H:
H = [12/(18×19)] × [(21²/6)+(57²/6)+(93²/6)] − 3×19
H = [12/342] × [73.5+541.5+1441.5] − 57
H = 0.03509 × 2056.5 − 57 = 72.17 − 57 = H = 15.17

6

Decision: df = 2, χ²(0.05, 2) = 5.991. H = 15.17 > 5.991. p < 0.001. Reject H₀.

✅ Conclusion: H(2) = 15.17, p < 0.001. Campaign type significantly affects conversion rates. Flash sale campaigns have the highest median conversion rate (Mdn = 5.95%), standard newsletters the lowest (Mdn = 1.95%). All pairwise post hoc comparisons are significant, confirming each campaign type is distinct in performance.

Dunn's Post Hoc Test — Step by Step

When the Kruskal-Wallis test returns a significant result, you know at least one group differs, but not which one. Dunn's test compares every pair of groups using the same ranks from the original test. This is more appropriate than running separate Mann-Whitney U tests for each pair, because Dunn's test accounts for the fact that multiple comparisons inflate the Type I error rate. The standard correction is the Bonferroni method.

Dunn's Test Procedure

For each pair of groups i and j, compute the z-statistic:

Dunn's Test Z-Statistic
z_ij = (R̄ᵢ − R̄ⱼ) / SE_ij
SE_ij = √[(N(N+1)/12) × (1/nᵢ + 1/nⱼ)]
R̄ᵢ = mean rank of group i R̄ⱼ = mean rank of group j N = total observations

Compare |z_ij| against the standard normal critical value at the Bonferroni-adjusted significance level α' = α / m, where m = k(k−1)/2 is the total number of pairwise comparisons. For three groups, m = 3; for four groups, m = 6.

Applying Dunn's test to Example 1 (three teaching methods, N = 15, n = 5 per group):

PairR̄ᵢR̄ⱼSE|z|p (raw)p (Bonferroni)Significant?
A vs B3.08.02.02.500.0120.037Yes
A vs C3.013.02.05.00<0.001<0.001Yes
B vs C8.013.02.02.500.0120.037Yes

SE = √[(15×16/12) × (1/5 + 1/5)] = √[20 × 0.4] = √8 = 2.0. All three pairs are significant at α = 0.05 after Bonferroni correction (α' = 0.0167; critical |z| = 2.394). Because |z| values of 2.50 exceed 2.394 for A vs B and B vs C, those differences are just significant at the adjusted level.

Kruskal-Wallis vs Other Tests

Kruskal-Wallis vs One-Way ANOVA

Feature Kruskal-Wallis Test One-Way ANOVA
TypeNonparametricParametric
Data requirementOrdinal or continuousContinuous (interval/ratio)
Normality assumptionNot requiredRequired (residuals normal)
Equal variancesNot requiredRequired (homoscedasticity)
What it testsMedians (rank distributions)Means
Test statisticH (approximates χ²)F
Post hoc testDunn's testTukey HSD, Bonferroni, Scheffé
Statistical power~95% of ANOVA when normalMaximum when normal
Minimum group sizeAs low as 1 (exact tables)Typically n ≥ 20 per group
When to chooseNon-normal, ordinal, outliers, small nNormal data, continuous, large n

Kruskal-Wallis vs Mann-Whitney U vs Friedman

Feature Kruskal-Wallis Mann-Whitney U Friedman Test
Groups3 or moreExactly 23 or more
DesignIndependent samplesIndependent samplesRelated samples
Parametric equivalentOne-way ANOVAIndependent t-testRepeated measures ANOVA
Test statisticHUQ
Use when3+ independent groups, nonparametric2 independent groups, nonparametricSame subjects measured multiple times

For the two-group case, see the Mann-Whitney U test guide. For related samples across multiple conditions, the Friedman test is the nonparametric alternative to repeated measures ANOVA.

Real-Life Applications of the Kruskal-Wallis Test

🏥

Healthcare & Medicine

Comparing pain scores (NRS) across drug treatment groups; recovery times between surgical techniques; side effect severity ratings across dosage levels. Pain and severity scales are inherently ordinal.

🎓

Education Research

Comparing test scores across teaching methods with small class sizes; analyzing Likert-scale student engagement ratings across three course formats; evaluating performance across school types.

🧠

Psychology & Social Science

Comparing stress, depression, or anxiety scale scores across three diagnostic groups; rating scale responses on quality-of-life instruments; attitude surveys across demographic groups.

🌾

Agriculture

Crop yield comparisons across fertilizer treatments or irrigation methods when plot sizes are small and yield distributions are skewed. Yield data frequently contains extreme outliers due to weather variation.

📊

Marketing & Business

Comparing customer satisfaction Likert scores across brands or service channels; conversion rates across three advertising formats; Net Promoter Score differences across regional offices.

⚙️

Manufacturing & Quality

Comparing defect rates (counts, which are discrete) across three production lines; customer complaint severity ratings across factory shifts; inspection scores across supplier grades.

When to Use the Kruskal-Wallis Test

Decision Tree — Should You Use the Kruskal-Wallis Test?

Do you have 3 or more independent groups?
→ No
Use Mann-Whitney U Test (2 groups) or a one-sample test
Is your outcome variable at least ordinal?
→ No
Use Chi-Square Test of Independence for categorical outcomes
Are observations independent (not matched/repeated)?
→ No
Use Friedman Test (nonparametric repeated measures)
Can you confirm normality of residuals across groups?
→ Yes
One-Way ANOVA is preferred (more statistical power)
Normality cannot be confirmed, data is ordinal, or n is small
✅ Use the Kruskal-Wallis Test

The RANK Framework for the Kruskal-Wallis Test

The RANK framework is an original mnemonic for executing the Kruskal-Wallis test correctly, from data checking through to final reporting.

RANK — The 8-Step Kruskal-Wallis Framework

R
Review assumptions — independence, ordinal/continuous outcome, 3+ groups, similar shapes
A
Arrange all observations into ranks — pool all groups, assign 1 to N from smallest to largest, average ties
N
Note group rank sums — calculate Rᵢ for each group and verify: ΣRᵢ = N(N+1)/2
K
Keep track of ties — count tied values and compute the tie-correction factor C before finalizing H
F
Find the H statistic — apply the formula: H = [12/(N(N+1))] × Σ[Rᵢ²/nᵢ] − 3(N+1), then divide by C
R
Read the p-value — compare H to χ² with df = k−1; reject H₀ if p < α
A
Apply post hoc tests — if H₀ rejected, run Dunn's test with Bonferroni correction for pairwise comparisons
M
Measure and report — state H(df), p-value, median per group, effect size (η²_H), and a plain-language conclusion

Common Mistakes with the Kruskal-Wallis Test

MistakeWhat Goes WrongCorrect Approach
Running Kruskal-Wallis on paired data Violates the independence assumption; inflated Type I error Use the Friedman test for repeated measures or matched groups
Skipping the tie correction H is underestimated, reducing power when many ties exist Apply C = 1 − Σ(t³−t)/(N³−N) whenever three or more tied values appear
Running multiple Mann-Whitney U tests instead of Dunn's test Multiplies the Type I error rate; α inflates beyond 0.05 with each additional test Use Dunn's test with Bonferroni correction for all pairwise post hoc comparisons
Treating Kruskal-Wallis as always testing medians When distribution shapes differ markedly, the test compares mean ranks, not medians Verify similar distribution shapes; report the test as comparing rank distributions if shapes differ
Using it for nominal (unordered) data Ranking nominal categories is meaningless; results are uninterpretable Use the chi-square test of independence for unordered categorical outcomes
Not reporting effect size The reader has no sense of practical significance Report η²_H = (H − k + 1)/(N − k). Values of 0.01, 0.06, 0.14 are small, medium, large.
Using it when ANOVA is appropriate Kruskal-Wallis loses ~5% efficiency compared to ANOVA when normality holds When normality is confirmed (e.g., by Shapiro-Wilk test), prefer one-way ANOVA for its higher power

Kruskal-Wallis Test Calculator

Enter your group data below — one value per line for each group. The calculator ranks all observations, computes the H statistic with tie correction, finds the p-value from the chi-square distribution, and makes a decision at your chosen α level.

Kruskal-Wallis H Statistic Calculator

Entity & Formula Glossary

Term / EntityDefinitionIn the Kruskal-Wallis Context
Kruskal-Wallis TestNonparametric one-way analysis of variance based on ranksThe primary test covered on this page
H StatisticThe Kruskal-Wallis test statistic; approximates χ² under H₀H = [12/(N(N+1))] × Σ[Rᵢ²/nᵢ] − 3(N+1)
RankPosition of an observation when all values are sorted 1 to NTied values receive the mean of their occupied ranks
MedianMiddle value of a sorted dataset; 50th percentileThe Kruskal-Wallis test compares medians (when shapes are similar)
Independent SamplesEach observation belongs to exactly one group with no pairingRequired assumption for the Kruskal-Wallis test
Nonparametric TestA test that does not assume a specific population distributionKruskal-Wallis requires no normality assumption
One-Way ANOVAParametric test comparing means of 3+ independent groupsThe parametric equivalent; use when normality holds
Dunn's TestPost hoc pairwise comparison test using Kruskal-Wallis ranksRun after a significant Kruskal-Wallis to identify differing pairs
Effect Size (η²_H)Proportion of variance in ranks explained by group membershipη²_H = (H − k + 1)/(N − k)
p-valueProbability of observing H this large if H₀ were trueCompare to α to decide whether to reject H₀
Null Hypothesis (H₀)The default claim of no differenceH₀: All group medians are equal
Alternative Hypothesis (H₁)The claim being testedH₁: At least one group median differs
Tie CorrectionAdjustment to H when multiple observations share the same valueC = 1 − Σ(t³−t)/(N³−N); H_adj = H/C
Chi-Square DistributionThe distribution H approximates under H₀df = k − 1 where k = number of groups
Bonferroni CorrectionDivides α by the number of comparisons to control Type I errorα' = α/m where m = k(k−1)/2 comparisons
William KruskalAmerican statistician (1919–2005), co-developer of the testPublished the test with W. Allen Wallis in 1952
W. Allen WallisAmerican economist and statistician (1912–1998)Co-developer; also served as US Undersecretary of State for Economic Affairs

How to Report Kruskal-Wallis Results

Statistical reporting standards ask for the test statistic, degrees of freedom, p-value, and a measure of effect size. Here is the APA 7th edition format, using Example 1's results:

APA 7th Edition Reporting Format

Template

A Kruskal-Wallis test was conducted to compare [outcome] among [k groups]. There was a statistically significant difference between the groups, H([df]) = [H], p = [p], η²_H = [value]. Post hoc pairwise comparisons using Dunn's test with Bonferroni correction indicated that [Group X] (Mdn = [value]) differed significantly from [Group Y] (Mdn = [value], p = [value]).

Example 1 Report

"A Kruskal-Wallis test was conducted to compare exam scores among three teaching methods (lecture only, discussion-based, and flipped classroom). There was a statistically significant difference between the groups, H(2) = 12.5, p = .002, η²_H = .875. Post hoc pairwise comparisons using Dunn's test with Bonferroni correction indicated that the flipped classroom (Mdn = 83) produced significantly higher scores than the discussion method (Mdn = 72, p = .037) and the lecture method (Mdn = 60, p < .001)."

Frequently Asked Questions

The Kruskal-Wallis test is a nonparametric statistical test that compares the medians of three or more independent groups. It is the rank-based equivalent of one-way ANOVA and does not require the data to be normally distributed. All observations from all groups are pooled and ranked together; the test statistic H measures whether the rank sums differ more than expected by chance. When H is large (and p < α), at least one group has a different median. The test was developed by William Kruskal and W. Allen Wallis and published in the Journal of the American Statistical Association in 1952.

Choose the Kruskal-Wallis test when at least one of these conditions is present: your outcome is ordinal (like Likert scale ratings); your continuous data is clearly non-normal (skewed, heavy tails, outliers); your sample size per group is too small to verify normality reliably (roughly n < 20); or a Shapiro-Wilk test or Q-Q plot shows normality is violated. When data is continuous and normally distributed, one-way ANOVA is preferred because it has slightly more statistical power. The difference in power is small — about 5% — when normality actually holds.

A significant result (p < α) means that at least one group has a statistically different median (or rank distribution) from at least one other group. It does not identify which groups differ — that requires a post hoc test such as Dunn's test. It also does not mean the difference is practically important; report effect size (η²_H) alongside the p-value so readers can judge the magnitude of the difference.

The H statistic has no fixed interpretation on its own — it must be compared to a critical value from the chi-square distribution with df = k − 1, where k is the number of groups. A larger H value means the rank sums deviate more from what equal medians would predict. If H > χ²(α, df), the result is significant and you reject H₀. Most researchers report H, degrees of freedom, and the p-value together rather than interpreting H in isolation.

Dunn's test is a post hoc pairwise comparison test used after a significant Kruskal-Wallis result to identify exactly which group pairs differ. It uses the same ranks from the original test and applies the Bonferroni correction (or other corrections such as Holm or Benjamini-Hochberg) to control the Type I error rate across multiple comparisons. Dunn's test is the standard post hoc choice for the Kruskal-Wallis test, available in R (via the dunn.test or FSA package), Python (via SciPy's posthoc_dunn), SPSS, and SAS.

Yes. The Kruskal-Wallis test handles unequal group sizes (unbalanced designs) without any modification. The formula uses the individual group sizes nᵢ explicitly. However, very small groups (n = 1 or 2) reduce power substantially, and extremely unequal sizes can affect the interpretation when distributions also differ in shape. For exact Kruskal-Wallis critical values with very small samples, use published nonparametric tables rather than the chi-square approximation.

Both are nonparametric tests for three or more groups, but they differ in design. The Kruskal-Wallis test is for independent samples — each subject appears in only one group. The Friedman test is for related samples — the same subjects (or matched subjects) are measured under each condition. Using Kruskal-Wallis on repeated-measures data violates the independence assumption and gives incorrect results; the Friedman test is the correct nonparametric alternative to repeated measures ANOVA. See the full comparison in the parametric vs nonparametric tests guide.

In R:

kruskal.test(score ~ group, data = df)
# Post hoc:
library(dunn.test)
dunn.test(df$score, df$group, method = "bonferroni")

In Python (SciPy):

from scipy import stats
H, p = stats.kruskal(group1, group2, group3)
# Post hoc (scikit-posthocs):
import scikit_posthocs as sp
sp.posthoc_dunn([group1, group2, group3], p_adjust='bonferroni')

The most widely reported effect size for the Kruskal-Wallis test is eta-squared (η²_H), calculated as η²_H = (H − k + 1) / (N − k). Using Cohen's (1988) guidelines adapted for this statistic: values around 0.01 indicate a small effect, 0.06 a medium effect, and 0.14 a large effect. Some researchers also report ε² (epsilon-squared) = (H − k + 1)/(N − k), which gives the same formula. Always report the effect size alongside H and p so readers can judge practical significance independently of sample size.

The chi-square approximation for the p-value works reasonably well when each group has at least 5 observations. With smaller groups, the chi-square p-value is not accurate; use exact Kruskal-Wallis critical value tables instead (published in most nonparametric statistics textbooks, including Conover's Practical Nonparametric Statistics). Some software offers exact p-values for small samples via Monte Carlo permutation. There is no strict minimum, but power will be very low with n < 3 per group regardless of method.

Sources and References

All formulas, examples, and procedures on this page are derived from primary statistical literature and leading educational institutions. The Kruskal-Wallis H formula and tie-correction factor are verified against the NIST Engineering Statistics Handbook and the original 1952 publication.

  • Kruskal, W.H. and Wallis, W.A. (1952) — "Use of ranks in one-criterion variance analysis." Journal of the American Statistical Association, 47(260), 583–621. JSTOR
  • NIST Engineering Statistics Handbook — Section 7.4.3: Kruskal-Wallis Test. National Institute of Standards and Technology. itl.nist.gov
  • Penn State STAT 415 — Nonparametric Methods. Penn State Eberly College of Science. online.stat.psu.edu
  • Conover, W.J. (1999)Practical Nonparametric Statistics (3rd ed.). Wiley. Standard reference for Kruskal-Wallis exact tables and Dunn's test procedure.
  • Dunn, O.J. (1964) — "Multiple comparisons using rank sums." Technometrics, 6(3), 241–252. Original source for the Dunn's test procedure.
  • SciPy Documentationscipy.stats.kruskal. Scientific Python. docs.scipy.org
  • OpenStax Introductory Statistics — Chapter 13: Nonparametric Tests. Rice University. openstax.org