0
$\begingroup$

My textbook states the following formula to calculate the H-value of the Kruskal-Wallis test (without tie ranks):

enter image description here

Let's use this formula to compute H for a really simple example dataset:

  • group 1 measurements: 10, 20
  • group 2 measurements: 30, 40

In the give example dataset the population size $N = 4$. The population consists of two groups each having two members ($n_i = 2$ for all $i$). When we rank the data we see, that group 1 contains rank 1 and 2, while group 2 contains rank 3 and 4. The squared sums of ranks for the groups are therefore $R_1^2=(1+2)^2=9$ and $R_2^2=(3+4)^2=49$. If we fill this into the formula we and up with

$H = \frac{12}{4*3}*(\frac{9}{2}+\frac{49}{2})-3*5 = 14$

So H should be 14. However, if I use the Kruskal-Wallis implementation of scipy I get a H-value of about 2.4.

from scipy.stats import kruskal

res = kruskal(np.array([10, 20]), np.array([30, 40]))
print(res)

What am I doing wrong in my computation?

$\endgroup$
1
$\begingroup$

Forget about it, checking the scipy code I realized that the formula in my textbook is just false. Correct formula starts with $\frac{12}{N(N+1)}$ not with $\frac{12}{N(N-1)}$

$\endgroup$
  • $\begingroup$ yes, that's correct. (And it does account for the entire difference, I made an error in my earlier comment) $\endgroup$ – Glen_b -Reinstate Monica Jan 3 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.