The test proceeds as follows:
-
(a)The pooled sample of all the observations is ranked. Average ranks are assigned to tied scores.
-
(b)The ranks of the observations in each sample are summed, to give the rank sums , for .
-
(c)The Kruskal–Wallis' test statistic is computed as:
i.e., is the total number of observations. If there are tied scores, is corrected by dividing by:
where is the number of tied scores in a group and the summation is over all tied groups.
g08afc returns the value of
, and also an approximation,
, to the probability of a value of at least
being observed,
is true. (
approximately follows a
distribution).
is rejected by a test of chosen size
if
The approximation
is acceptable unless
and
,
or
in which case tables should be consulted (e.g., O of
Siegel (1956)) or
(in which case the Median test (see
g08acc) or the Mann–Whitney
test (see
g08amc) is more appropriate).
-
1:
– Integer
Input
-
On entry: the number of samples, .
Constraint:
.
-
2:
– const Integer
Input
-
On entry: must contain the number of observations in sample , for .
Constraint:
, for .
-
3:
– const double
Input
-
On entry: the elements of
x must contain the observations in the
k groups. The first
elements must contain the scores in the first group, the next
those in the second group, and so on.
-
4:
– Integer
Input
-
On entry: the total number of observations, .
Constraint:
.
-
5:
– double *
Output
-
On exit: the value of the Kruskal–Wallis test statistic, .
-
6:
– double *
Output
-
On exit: the approximate significance, , of the Kruskal–Wallis test statistic.
-
7:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
For estimates of the accuracy of the significance
, see
g01ecc. The
approximation is acceptable unless
and
or
.
Background information to multithreading can be found in the
Multithreading documentation.
This example is taken from Moore
et al. Moore et al. (1972). There are 5 groups of sizes
,
,
, 8 and
. The data represent the weight gain, in pounds, of pigs from five different litters under the same conditions.