17.5.6.2 Algorithms (Kruskal-Wallis ANOVA)

The procedure below draws on NAG algorithms.

  1. Rank all observation in ascending order. Average ranks are assigned to tied scores
  2. Sum up the ranks of observations in each group, to give the ranks sums  R_i \,\!, for  i=1,2,\ldots ,k \,\!
  3. The Kruskal-Wallis test statistic  H \,\! is computed as:  H=\frac{12}{N(N+1)}\sum_{i=1}^k\frac{R_i^2}{l_i}-3(N+1) \,\! where  N=\sum_{i=1}^kl_i\,\!, i.e.  N \,\! is the total number of observations. If there are tied scores,  H \,\!is corrected by dividing by  1-\frac{\sum (t^3-t)}{N^3-N}\,\!where  t \,\! is the number of tied scores in a group and the summation is overall tied groups.

The significance level is based on the \chi ^2\,\! distribution, with  k-1 \,\! degree of freedom.

For more details of the algorithm, please refer to nag_kruskal_wallis_test (g08afc)