PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_nonpar_test_friedman (g08ae)
Purpose
nag_nonpar_test_friedman (g08ae) performs the Friedman two-way analysis of variance by ranks on related samples of size .
Syntax
[
fr,
p,
ifail] = nag_nonpar_test_friedman(
x, 'k',
k, 'n',
n)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 22: |
k was made optional |
Description
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_nonpar_test_friedman (g08ae) 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
, tables should be consulted (e.g.,
Siegel (1956)); for
the Sign test (see
nag_nonpar_test_sign (g08aa)) or Wilcoxon test (see
nag_nonpar_test_wilcoxon (g08ag)) is in any case more appropriate.
References
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
Parameters
Compulsory Input Parameters
- 1:
– double array
-
ldx, the first dimension of the array, must satisfy the constraint
.
must be set to the value, , of observation in sample , for and .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
x.
, the number of samples.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
x.
, the size of each sample.
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The value of the Friedman test statistic, .
- 2:
– double scalar
-
The approximate significance, , of the Friedman test statistic.
- 3:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
-
-
-
-
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
Dynamic memory allocation failed.
Accuracy
For estimates of the accuracy of the significance
, see
nag_stat_prob_chisq (g01ec). The
approximation is acceptable unless
and
, or
and
, or
and
.
Further Comments
The time taken by nag_nonpar_test_friedman (g08ae) is approximately proportional to the product .
If
, the Sign test (see
nag_nonpar_test_sign (g08aa)) or Wilcoxon test (see
nag_nonpar_test_wilcoxon (g08ag)) is more appropriate.
Example
This example is taken from page 169 of
Siegel (1956). The data relates to training scores of three matched samples of
rats, trained under three different patterns of reinforcement.
Open in the MATLAB editor:
g08ae_example
function g08ae_example
fprintf('g08ae example results\n\n');
x = [1, 2, 1, 1, 3, 2, 3, 1, 3, 3, 2, 2, 3, 2, 2.5, 3, 3, 2;
3, 3, 3, 2, 1, 3, 2, 3, 1, 1, 3, 3, 2, 3, 2.5, 2, 2, 3;
2, 1, 2, 3, 2, 1, 1, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1];
fprintf('Friedman test\n\n');
mtitle = 'Data values';
matrix = 'General';
diag = ' ';
[ifail] = x04ca( ...
matrix, diag, x, mtitle);
[fr, p, ifail] = g08ae(x);
fprintf('\nTest statistic %6.3f\n', fr);
fprintf('Degrees of freedom %6d\n', size(x,1)-1);
fprintf('Significance %6.3f\n', p);
g08ae example results
Friedman test
Data values
1 2 3 4 5 6 7
1 1.0000 2.0000 1.0000 1.0000 3.0000 2.0000 3.0000
2 3.0000 3.0000 3.0000 2.0000 1.0000 3.0000 2.0000
3 2.0000 1.0000 2.0000 3.0000 2.0000 1.0000 1.0000
8 9 10 11 12 13 14
1 1.0000 3.0000 3.0000 2.0000 2.0000 3.0000 2.0000
2 3.0000 1.0000 1.0000 3.0000 3.0000 2.0000 3.0000
3 2.0000 2.0000 2.0000 1.0000 1.0000 1.0000 1.0000
15 16 17 18
1 2.5000 3.0000 3.0000 2.0000
2 2.5000 2.0000 2.0000 3.0000
3 1.0000 1.0000 1.0000 1.0000
Test statistic 8.583
Degrees of freedom 2
Significance 0.014
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015