The Kruskal-Wallis test is a nonparametric method for comparing three or more independent groups when a one-way ANOVA is not appropriate. It is especially useful when the response variable is ordinal, strongly skewed, or affected by outliers. This cheat sheet helps students identify when to use the test, compute the test statistic, and interpret results correctly.
It also connects the test to post hoc comparisons after a significant result.
The core idea is to rank all observations together, then compare the average ranks across groups. If the groups come from similar distributions, their rank averages should be close. The main statistic is , with a tie correction when needed.
Under the null hypothesis and typical large-sample conditions, is compared to a chi-square distribution with .
Key Facts
- Use the Kruskal-Wallis test to compare independent groups when the response is ordinal or a continuous variable that does not meet ANOVA assumptions.
- The null hypothesis is : all groups have the same distribution, often interpreted as equal population medians when group distributions have similar shapes.
- The alternative hypothesis is : at least one group tends to have larger or smaller values than at least one other group.
- Rank all observations from smallest to largest across all groups, assigning average ranks to tied values.
- For group , let be the group size and be the sum of ranks in that group.
- The Kruskal-Wallis statistic is .
- When ties occur, use the corrected statistic , where is the size of tie group .
- For large enough samples, compare or to and reject when the -value is less than .
Vocabulary
- Kruskal-Wallis test
- A nonparametric hypothesis test used to compare three or more independent groups using ranks instead of raw data values.
- Rank sum
- The rank sum is the total of all ranks assigned to observations in group .
- Degrees of freedom
- For the Kruskal-Wallis test, the degrees of freedom are , where is the number of groups.
- Tie correction
- A tie correction adjusts the statistic when equal data values create tied ranks.
- Post hoc comparison
- A post hoc comparison tests which specific group pairs differ after the overall Kruskal-Wallis test is significant.
- Nonparametric test
- A nonparametric test makes fewer assumptions about the population distribution than a parametric test such as ANOVA.
Common Mistakes to Avoid
- Using Kruskal-Wallis for paired or repeated-measures data is wrong because the test assumes independent groups. Use a related-samples method such as the Friedman test when the same subjects are measured repeatedly.
- Interpreting a significant result as proof that all group medians are different is wrong because the test only shows that at least one group differs in distribution or location.
- Forgetting to rank all observations together is wrong because ranks must be assigned across the full combined sample, not separately within each group.
- Ignoring ties can give an inaccurate test statistic because tied values reduce the variability of ranks. Apply the tie-corrected statistic when ties are present.
- Running many pairwise tests without adjustment is wrong because it inflates the Type I error rate. Use a correction such as Bonferroni, Holm, or Dunn's test with adjusted -values.
Practice Questions
- 1 Three independent groups have , , , and rank sums , , . Compute .
- 2 A Kruskal-Wallis test compares independent groups and gives . What are the degrees of freedom, and how would you use to find or approximate the -value?
- 3 A data set has observations with one tie group of size and another tie group of size . Compute the tie correction denominator factor .
- 4 A researcher compares exam scores from three different classes and finds a significant Kruskal-Wallis result. Explain why this result does not by itself identify which classes differ.