Logo

Data Learning Center Statistical Guides

Kruskal-Wallis rank sum test

 Typically, data sets with some continuous measurement that contain more than two groups are compared using the one-way Analysis of Variance (ANOVA1). For instance, we may be interested in determining if the abundances of Phosphorous in soils are the same among three different sites, or if the height of specific plant species grown for 8-weeks differs between four different temperature conditions. However, there are instances when the ANOVA1 may not be appropriate, such as when the data is ordinal or there are certain assumptions for the ANOVA1 that are violated, specifically when the groups are not approximately normal distributions, has outliers, or is an unbalanced design with unequal variances. In these cases we can instead apply the Kruskal-Wallis rank sum test, which as a non-parametric test has a different set of assumptions:

 When these assumptions are met we can apply the Kruskal-Wallis rank sum test to statistically test the following null and alternative hypotheses:

H0: The population medians are equal
HA: At least one of the population medians are not equal with the other medians


 Similar with the ANOVA1, which calculates an F-statistic to approximate a p-value from an F-distribution, the Kruskal-Wallis rank sum test calculates an H-statistic to approximate a p-value from a χ2 distribution with g - 1 degrees of freedom, where g is the number of groups. This H-statistic is calculated by the formula:


where N is the total number of observations, ni is the number of observations in group i, i. is the average rank of all the observations in group i, ij is the rank of observation j from group i, and is the average of all ij.

 Note that results from the Kruskal-Wallis rank sum test can only be used to determine whether at least one of the groups has a distribution that is different from at least one of the other groups. Like the ANOVA1, post-hoc pairwise comparison tests are needed to determine which of those groups have statistically different distribution from one another. Common post-hoc tests for the Kruskal-Wallis rank sum test include the Dunn’s test and the Mann-Whitney U test with corrections.

Kruskal-Wallis rank sum test | DLC_statistical_guides