5  The Kruskal-Wallis test

two or more unrelated groups

Kruskal-Wallis test is an extension of the Wilcoxon rank sum test for unrelated \(k\) groups, where \(k\ge 2\). Under the null hypothesis of no differences in the distribution between the groups, the sums of the ranks in each of the \(k\) groups should be comparable after allowing for any differences in sample size.

In R one can use kruskal.test() to compute the test. Otherwise, the procedure is outlined below.

5.1 Define the null and alternative hypothesis

\(H_0:\) each group has the same distribution of values in the population

\(H_1:\) at least one group does not have the same distribution of values in the population

5.2 Calculate the value of the test statistics

Rank all \(n\) values and calculate the sum of the ranks in each of the groups: these sums are \(R_1, R_2, ..., R_k\). The test statistics is given by: \[ H = \frac{12}{n(n+1)}\displaystyle\sum_{i=1}^{n}\frac{R_i^2}{n_i}-3(n+1)\] which follows a \(\chi^2\) distribution with \((k-1)\) degrees of freedom.