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 sample and the summation is over all tied samples.
g08aff 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
g08acf) or the Mann–Whitney
test (see
g08ahf) is more appropriate).
-
1:
– Real (Kind=nag_wp) array
Input
-
On entry: the elements of
x must contain the observations in the
k samples. The first
elements must contain the scores in the first sample, the next
those in the second sample, and so on.
-
2:
– Integer
Input
-
On entry: , the total number of observations.
Constraint:
.
-
3:
– Integer array
Input
-
On entry: must contain the number of observations in sample , for .
Constraint:
, for .
-
4:
– Integer
Input
-
On entry: , the number of samples.
Constraint:
.
-
5:
– Real (Kind=nag_wp) array
Workspace
-
-
6:
– Real (Kind=nag_wp)
Output
-
On exit: the value of the Kruskal–Wallis test statistic, .
-
7:
– Real (Kind=nag_wp)
Output
-
On exit: the approximate significance, , of the Kruskal–Wallis test statistic.
-
8:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
For estimates of the accuracy of the significance
, see
g01ecf. 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. (1972). There are
groups of sizes
,
,
,
and
. The data represent the weight gain, in pounds, of pigs from five different litters under the same conditions.