What is the Kruskal Wallis Test?
The Kruskal Wallis test is a nonparametric hypothesis test that compares three or more independent groups. Statisticians also refer to it as one-way ANOVA on ranks. This analysis extends the Mann Whitney U nonparametric test that can compare only two groups.
If you analyze data, chances are you’re familiar with one-way ANOVA that compares the means of at least three groups. The Kruskal Wallis test is the nonparametric version of it. Because it is nonparametric, the analysis makes fewer assumptions about your data than its parametric equivalent.
Many analysts use the Kruskal Wallis test to determine whether the medians of at least three groups are unequal. However, it’s important to note that it only assesses the medians in particular circumstances. Interpreting the analysis results can be thorny. More on this later!
If you need a nonparametric test for paired groups or a single sample, consider the Wilcoxon signed rank test.
Learn more about Parametric vs. Nonparametric Tests and Hypothesis Testing Overview.
What Does the Kruskal Wallis Test Tell You?
At its core, the Kruskal Wallis test evaluates data ranks. The procedure ranks all the sample data from low to high. Then it averages the ranks for all groups. If the results are statistically significant, the average group ranks are not all equal. Consequently, the analysis indicates whether any groups have values that rank differently. For instance, one group might have values that tend to rank higher than the other groups.
The Kruskal Wallis test doesn’t involve medians or other distributional properties—just the ranks. In fact, by evaluating ranks, it rolls up both the location and shape parameters into a single evaluation of each group’s average rank.
When their average ranks are unequal, you know a group’s distribution tends to produce higher or lower values than the others. However, you don’t know enough to draw conclusions specifically about the distributions’ locations (e.g., the medians).
Special Case for Same Shapes
However, when you hold the distribution shapes constant, the Kruskal Wallis test does tell us about the median. That’s not a property of the procedure itself but logic. If several distributions have the same shape, but the average ranks are shifted higher and lower, their medians must differ. But we can only draw that conclusion about the medians when the distributions have the same shapes.
These three distributions have the same shape, but the red and green are shifted right to higher values. Wherever the median falls on the blue distribution, it’ll be in the corresponding position in the red and blue distributions. In this case, the analysis can assess the medians.
But, if the shapes aren’t similar, we don’t know whether the location, shape, or a combination of the two produced the statistically significant Kruskal Wallis test.
Analysis Assumptions
Like all statistical analyses, the Kruskal Wallis test has assumptions. Ensuring that your data meet these assumptions is crucial.
- Independent Groups: Each group has a distinct set of subjects or items.
- Independence of Observations: Each observation must be independent of the others. The data points should not influence or predict each other.
- Ordinal or Continuous Data: The Kruskal Wallis test can handle both ordinal data and continuous data, making it flexible for various research situations.
- Same Distribution Shape: This assumption applies only when you want to draw inferences about the medians. If this assumption holds, the analysis can provide insights about the medians.
Violating these assumptions can lead to incorrect conclusions.
When to Use this Analysis?
Consider using the Kruskal Wallis test in the following cases:
- You have ordinal data.
- Your data follow a nonnormal distribution, and you have a small sample size.
- The median is more relevant to your subject area than the mean.
Learn more about the Normal Distribution.
If you have 3 – 9 groups and more than 15 observations per group or 10 – 12 groups and more than 20 observations per group, you might want to use one-way ANOVA even when you have nonnormal data. The central limit theorem causes the sampling distributions to converge on normality, making ANOVA a suitable choice.
One-way ANOVA has several advantages over the Kruskal Wallis test, including the following:
- More statistical power to detect differences.
- Can handle distributions with different shapes (Use Welch’s ANOVA).
- Avoids the interpretation issues discussed above.
In short, use this nonparametric method when you’re specifically interested in the medians, have ordinal data, or can’t use one-way ANOVA because you have a small, nonnormal sample.
Interpreting Kruskal Wallis Test Results
Like one-way ANOVA, the Kruskal Wallis test is an “omnibus” test. Omnibus tests can tell you that not all your groups are equal, but it doesn’t specify which pairs of groups are different.
Specifically, the Kruskal Wallis test evaluates the following hypotheses:
- Null: The average ranks are all the same.
- Alternative: At least one average rank is different.
Again, if the distributions have similar shapes, you can replace “average ranks” with “medians.”
Imagine you’re studying five different diets and their impact on weight loss. The Kruskal Wallis test can confirm that at least two diets have different results. However, it won’t tell you exactly which pairs of diets have statistically significant differences.
So, how do we solve this problem? Enter post hoc tests. Perform these analyses after (i.e., post) an omnibus analysis to identify specific pairs of groups with statistically significant differences. A standard option includes Dunn’s multiple comparisons procedure. Other options include performing a series of pairwise Mann-Whitney U tests with a Bonferroni correction or the lesser-known but potent Conover-Iman method.
Learn about Post Hoc Tests for ANOVA.
Kruskal Wallis Test Example
Imagine you’re a healthcare administrator analyzing the median number of unoccupied beds in three hospitals. Download the CSV dataset: KruskalWallisTest.
For this Kruskal Wallis test, the p-value is 0.029, which is less than the typical significance level of 0.05. Consequently, we can reject the null hypothesis that all groups have the same average rank. At least one group has a different average rank than the others.
Furthermore, if the three hospital distributions have the same shape, we can conclude that the medians differ.
At this point, we might decide to use a post hoc test to compare pairs of hospitals.
Muhammad Hafeez says
Sir kruskal walllis test is Two tailed or one tailed test??
Jim Frost says
It’s a one-tailed test in the same sense that the F-test for one-way ANOVA is one-tailed.