Kruskal-Wallis Test Calculator
Non-parametric test for 3+ groups.
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 A | Group B | Group C |
|---|---|---|
| 23 | 31 | 45 |
| 18 | 28 | 42 |
| 25 | 35 | 38 |
Ranked:
| Value | Rank | Group |
|---|---|---|
| 18 | 1 | A |
| 23 | 2 | A |
| 25 | 3 | A |
| 28 | 4 | B |
| 31 | 5 | B |
| 35 | 6 | B |
| 38 | 7 | C |
| 42 | 8 | C |
| 45 | 9 | C |
Step 2: Calculate Rank Sums
Step 3: Calculate H Statistic
Where:
- = total sample size
- = number of groups
- = sum of ranks in group
- = sample size of group
Step 4: Determine P-Value
H approximately follows a chi-square distribution with degrees of freedom.
For , :
Conclusion: Significant difference between groups ().
Tie Correction
When values are tied, apply a correction factor:
Where 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
| Aspect | ANOVA | Kruskal-Wallis |
|---|---|---|
| Assumption | Normal distributions | No normality required |
| Data type | Continuous | Ordinal or continuous |
| Compares | Means | Distributions/medians |
| Power (normal data) | Higher | ~95% of ANOVA |
| Outliers | Sensitive | Robust |
| Sample size | Can be small | Better 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:
- Calculate pairwise z-statistics using rank sums
- Apply Bonferroni or other correction for multiple comparisons
- Identify which pairs differ significantly
Conover-Iman Test
Alternative that uses t-distribution:
- Convert ranks to t-statistics
- Perform pairwise t-tests on ranks
- Apply multiple comparison correction
Dwass-Steel-Critchlow-Fligner
A step-down procedure that controls family-wise error rate.
Effect Size
Epsilon-Squared
| Ρ² | Interpretation |
|---|---|
| 0.01 | Small |
| 0.06 | Medium |
| 0.14 | Large |
Eta-Squared Based on H
Example: Complete Analysis
Scenario: Compare pain relief ratings (1-10) for three medications.
| Drug A | Drug B | Drug C |
|---|---|---|
| 3 | 6 | 8 |
| 4 | 5 | 7 |
| 2 | 7 | 9 |
| 5 | 4 | 6 |
| 3 | 6 | 8 |
Step 1: Rank all 15 observations (handle ties by average rank)
Step 2: Calculate rank sums
Step 3: Calculate H
Step 4: P-value with df = 2:
Conclusion: Significant difference in pain relief (, ). 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
- One-Way ANOVA β Parametric alternative
- Mann-Whitney U Test β Two-group non-parametric test
- Friedman Test β Non-parametric repeated measures
- Tukey HSD Calculator β Post-hoc for ANOVA
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.