nag_friedman_test (g08aec) performs the Friedman two-way analysis of variance by ranks on related samples of size .
The Friedman test investigates the score differences between
matched samples of size
, the scores in the
th sample being denoted by:
(Thus the sample scores may be regarded as a two-way table with
rows and
columns.) The hypothesis under test,
, often called the null hypothesis, is that the samples come from the same population, and this is to be tested against the alternative hypothesis
that they come from different populations.
The test is based on the observed distribution of score rankings between the matched observations in different samples.
The test proceeds as follows:
(a) |
The scores in each column are ranked, denoting the rank within column of the observation in row . Average ranks are assigned to tied scores. |
(b) |
The ranks are summed over each row to give rank sums , for . |
(c) |
The Friedman test statistic is computed, where
|
nag_friedman_test (g08aec) returns the value of
, and also an approximation,
, to the significance of this value. (
approximately follows a
distribution, so large values of
imply rejection of
).
is rejected by a test of chosen size
if
. The approximation
is acceptable unless
and
, or
and
, or
and
; for
or 4, tables should be consulted (e.g.,
n of
Siegel (1956)); for
the Sign test (see
nag_sign_test (g08aac)) or Wilcoxon test (see
nag_wilcoxon_test (g08agc)) is in any case more appropriate.
- 1:
k – IntegerInput
On entry:
, the number of samples.
Constraint:
.
- 2:
n – IntegerInput
On entry: the size of each sample, .
Constraint:
.
- 3:
x[] – const doubleInput
-
On entry: must be set to the value, , of observation in sample , for and .
- 4:
tdx – IntegerInput
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
- 5:
fr – double *Output
-
On exit: the value of the Friedman test statistic, .
- 6:
p – double *Output
-
On exit: the approximate significance, , of the Friedman test statistic.
- 7:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
For estimates of the accuracy of the significance
, see
nag_prob_chi_sq (g01ecc). The
approximation is acceptable unless
and
, or
and
, or
and
.
Not applicable.
The time taken by nag_friedman_test (g08aec) is approximately proportional to the product .
This example is taken from page 169 of
Siegel (1956). The data relate to training scores of three matched samples of 18 rats, trained under three different patterns of reinforcement.