Kruskal-Wallis test when $k=2$

I have heard that Kruskal-Wallis test with two groups is equivalent to the Wilcoxon rank sum test, but I can't figure out how to prove it. Could someone please help me prove that under the condition $$k=2$$ test statistics are equal?

• What have you tried? Dec 4, 2022 at 18:32
• @Galen I'm not sure how to do it. I think Kruskal-Wallis test statistic could be $\frac{12}{N(N+1)}( n_1(R_1-\frac{N+1}{2})^2 +n_2(R_2-\frac{N+1}{2})^2)$ but I dont know how to continue
– Lars
Dec 4, 2022 at 18:54
• Equivalence of tests does not imply the statistics are equal. It only means there is a one-to-one correspondence between the possible values of the test statistics. Thus, all you need to show is that (say) the sample size and the value of the Wilcoxon U statistic determine the KW statistic and vice versa. Intuitively, because the former is computed from the sum of ranks in one group (which determines the sum of ranks in the other group) and the latter is computed from the mean ranks in the groups, the correspondence amounts to that between a sum and a mean.
– whuber
Dec 4, 2022 at 19:59
• I agree with the spirit of what whuber was saying. Here is a footnote to it. In a usual sense of mathematical equivalence, any equality relation is an equivalence relation. There are various equivalences that are not equality but are also relevant because they are interesting or useful. Dec 4, 2022 at 20:45

You can show that $$H=\frac{(W_{n+m}-\mathbb{E}[W_{n+m}])^2}{Var_{H_0}(W_{n+m})}$$, where H denotes the Kruskal-Wallis test statistic for k=2 and $$W_{n+m}$$ is the Wilcoxon-rank-sum test statistic.

The Kruskal-Wallis test statistic is given by

$$H=\frac{12}{n(n+1)}\sum_{i=1}^{k}{\frac{1}{n_i}}(R_i-\frac{n_i(n+1)}{2})^2$$

with $$n=n_1+\dots+n_k$$.

For k=2 we obtain

$$H=\frac{12}{(n_1+n_2)(n_1+n_2+1)}(\frac{1}{n_1}(R_1-\frac{n_1(n_1+n_2+1)}{2})^2+\frac{1}{n_2}(R_2-\frac{n_2(n_1+n_2+1)}{2})^2)=\frac{12}{(n_1+n_2)(n_1+n_2+1)}\frac{1}{n_1n_2}(\frac{n_2(R_1-\frac{n_1(n_1+n_2+1)}{2})^2+n_1(R_2-\frac{n_2(n_1+n_2+1)}{2})^2}{n_1+n_2})=(\text{Var}_{H_0}(W_{n_1+n_2}))^{-1}(\frac{n_2(R_1-\frac{n_1(n_1+n_2+1)}{2})^2+n_1(R_2-\frac{n_2(n_1+n_2+1)}{2})^2}{n_1+n_2})$$

where $$(\text{Var}_{H_0}(W_{n_1+n_2}))^{-1}=\frac{12}{(n_1+n_2)(n_1+n_2+1)}\frac{1}{n_1n_2}$$.

Now we have $$R_2=\frac{(n_1+n_2)(n_1+n_2+1)}{2}-R_1$$ (*).This follows from the definition of the Wilcoxon-rank-sum test statistic. It is

$$R_2=\frac{n_2(n_2+1)}{2}+\sum_{i=1}^{n_2}\sum_{j=1}^{n_1}\mathbf{1}_{(y_i\geq x_j)} \\ =\frac{n_2(n_2+1)}{2}+\sum_{i=1}^{n_2}\sum_{j=1}^{n_1}(1-\mathbf{1}_{(y_i\leq x_j)})\\= \frac{n_2(n_2+1)}{2}+n_1n_2+\sum_{i=1}^{n_2}\sum_{j=1}^{n_1}\mathbf{1}_{(y_i\leq x_j)}\\ = \frac{n_2(n_2+1)}{2}+n_1n_2+(R_1+\frac{n_1(n_1+1)}{2})\\ =\frac{(n_1+n_2)(n_1+n_2+1)}{2}-R_1.$$

Substituting $$R_2$$ with (*) in the Kruskal-Wallis test statistic gives us

$$H=(\text{Var}_{H_0}(W_{n_1+n_2}))^{-1}\frac{1}{(n_1+n_2)}(n_2(R_1-\frac{n_1(n_1+n_2+1)}{2})^2+n_1(\frac{(n_1+n_2)(n_1+n_2+1)}{2}-R_1-\frac{n_2(n_1+n_2+1)}{2})^2)\\=(\text{Var}_{H_0}(W_{n_1+n_2}))^{-1}\frac{1}{(n_1+n_2)}(n_2(R_1-\frac{n_1(n_1+n_2+1)}{2})^2+n_1(\frac{n_1(n_1+n_2+1)}{2}-R_1)^2)\\=(\text{Var}_{H_0}(W_{n_1+n_2}))^{-1}\frac{(n_1+n_2)}{(n_1+n_2)}(R_1-\frac{n_1(n_1+n_2+1)}{2})^2\\=\frac{(W_{n_1+n_2}-\mathbb{E}[W_{n_1+n_2}])}{Var_{H_0}(W_{n_1+n_2})}^2$$

where $$R_1=W_{n_1+n_2}$$.