Kruskal-Wallis Test Calculator

Non-parametric test for 3+ groups.

Examples:

Enter data for 2+ groups to compare

Use the Kruskal-Wallis test when you want to compare three or more independent groups but your data violates the assumptions of ANOVAβ€”perhaps it's not normally distributed, contains outliers, or uses ordinal scales like satisfaction ratings. It tells you whether at least one group differs significantly from the others, making it a versatile tool for comparing groups without strict distributional requirements.

What Is the Kruskal-Wallis Test?

The Kruskal-Wallis H test is the non-parametric alternative to one-way ANOVA. It compares three or more independent groups when the assumption of normality cannot be met.

Question answered: "Do at least two groups have different distributions (medians)?"

Examples:

  • Compare customer satisfaction across 4 store locations (ordinal ratings)
  • Compare recovery times for 3 treatments (skewed data)
  • Compare test scores across 5 schools (non-normal distributions)

How It Works

Step 1: Rank All Observations

Combine all data and assign ranks from 1 to N (total sample size).

Group AGroup BGroup C
233145
182842
253538

Ranked:

ValueRankGroup
181A
232A
253A
284B
315B
356B
387C
428C
459C

Step 2: Calculate Rank Sums

  • RA=1+2+3=6R_A = 1 + 2 + 3 = 6
  • RB=4+5+6=15R_B = 4 + 5 + 6 = 15
  • RC=7+8+9=24R_C = 7 + 8 + 9 = 24

Step 3: Calculate H Statistic

H=12N(N+1)βˆ‘i=1kRi2niβˆ’3(N+1)H = \frac{12}{N(N+1)} \sum_{i=1}^{k} \frac{R_i^2}{n_i} - 3(N+1)

Where:

  • NN = total sample size
  • kk = number of groups
  • RiR_i = sum of ranks in group ii
  • nin_i = sample size of group ii

H=129(10)(363+2253+5763)βˆ’3(10)H = \frac{12}{9(10)} \left(\frac{36}{3} + \frac{225}{3} + \frac{576}{3}\right) - 3(10)

H=1290(279)βˆ’30=37.2βˆ’30=7.2H = \frac{12}{90}(279) - 30 = 37.2 - 30 = 7.2

Step 4: Determine P-Value

H approximately follows a chi-square distribution with kβˆ’1k - 1 degrees of freedom.

For H=7.2H = 7.2, df=2df = 2: pβ‰ˆ0.027p \approx 0.027

Conclusion: Significant difference between groups (p<0.05p < 0.05).

Tie Correction

When values are tied, apply a correction factor:

Hcorrected=H1βˆ’βˆ‘(t3βˆ’t)N3βˆ’NH_{corrected} = \frac{H}{1 - \frac{\sum(t^3 - t)}{N^3 - N}}

Where tt is the number of tied values at each rank.

Assumptions

Independent Observations

Observations within and between groups must be independent.

Ordinal Scale (Minimum)

Data must be at least ordinalβ€”values can be meaningfully ranked.

Similar Distribution Shape

Groups should have similarly shaped distributions (same general form, possibly shifted).

Note: The Kruskal-Wallis test compares distributions, not just medians. If distributions have different shapes, significant results may reflect shape differences rather than central tendency differences.

Comparison with One-Way ANOVA

AspectANOVAKruskal-Wallis
AssumptionNormal distributionsNo normality required
Data typeContinuousOrdinal or continuous
ComparesMeansDistributions/medians
Power (normal data)Higher~95% of ANOVA
OutliersSensitiveRobust
Sample sizeCan be smallBetter with n β‰₯ 5 per group

Post-Hoc Tests

A significant Kruskal-Wallis result indicates at least one group differs, but not which ones.

Dunn's Test

The most common post-hoc procedure:

  1. Calculate pairwise z-statistics using rank sums
  2. Apply Bonferroni or other correction for multiple comparisons
  3. Identify which pairs differ significantly

Conover-Iman Test

Alternative that uses t-distribution:

  1. Convert ranks to t-statistics
  2. Perform pairwise t-tests on ranks
  3. Apply multiple comparison correction

Dwass-Steel-Critchlow-Fligner

A step-down procedure that controls family-wise error rate.

Effect Size

Epsilon-Squared

Ο΅2=HNβˆ’1\epsilon^2 = \frac{H}{N - 1}

Ρ²Interpretation
0.01Small
0.06Medium
0.14Large

Eta-Squared Based on H

Ξ·H2=Hβˆ’k+1Nβˆ’k\eta^2_H = \frac{H - k + 1}{N - k}

Example: Complete Analysis

Scenario: Compare pain relief ratings (1-10) for three medications.

Drug ADrug BDrug C
368
457
279
546
368

Step 1: Rank all 15 observations (handle ties by average rank)

Step 2: Calculate rank sums

  • RA=18.5R_A = 18.5
  • RB=47.5R_B = 47.5
  • RC=54.0R_C = 54.0

Step 3: Calculate H

H=1215Γ—16(18.525+47.525+5425)βˆ’48=9.38H = \frac{12}{15 \times 16}\left(\frac{18.5^2}{5} + \frac{47.5^2}{5} + \frac{54^2}{5}\right) - 48 = 9.38

Step 4: P-value with df = 2: p=0.009p = 0.009

Conclusion: Significant difference in pain relief (H=9.38H = 9.38, p=0.009p = 0.009). Post-hoc tests needed to identify which drugs differ.

Applications

Medical Research

  • Compare treatment outcomes across multiple therapies
  • Analyze ordinal scales (pain, satisfaction, quality of life)
  • Handle non-normal biomarker distributions

Social Sciences

  • Compare Likert scale responses across groups
  • Analyze ranked preferences
  • Study ordinal variables (education level, income brackets)

Quality Control

  • Compare defect rates across production lines
  • Analyze customer ratings across locations
  • Evaluate performance across shifts

Common Mistakes

Using with Two Groups Only

With exactly two groups, use Mann-Whitney U test insteadβ€”it's more powerful.

Ignoring Distribution Shape Assumption

If distributions have very different shapes, significant results may not indicate median differences.

Not Performing Post-Hoc Tests

A significant H only indicates some difference existsβ€”post-hoc tests identify which pairs differ.

Treating as Direct Median Comparison

Kruskal-Wallis compares entire distributions. Report medians for interpretation, but understand the test is broader.

Reporting Results

APA format:

"A Kruskal-Wallis H test showed a statistically significant difference in pain relief ratings across three medications, H(2) = 9.38, p = .009, Ρ² = .67. Post-hoc Dunn's tests with Bonferroni correction indicated that Drug C (Mdn = 8) had significantly higher ratings than Drug A (Mdn = 3), p = .003, while Drug B (Mdn = 6) did not differ significantly from either."

Historical Context

William Kruskal and W. Allen Wallis developed this test in 1952 as an extension of the Mann-Whitney U test to multiple groups.

The test was part of a broader movement toward non-parametric statistics in the mid-20th century, providing researchers with robust alternatives to parametric methods.

Related Calculations

Summary

The Kruskal-Wallis H test compares three or more independent groups without requiring normality. It ranks all observations, calculates a test statistic based on rank sums, and compares to a chi-square distribution. Use it when data are ordinal, distributions are non-normal, or samples are small. A significant result requires post-hoc tests (Dunn's test) to identify which groups differ. Report H, degrees of freedom, p-value, effect size, and medians for each group.