hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_nonpar_test_friedman (g08ae)

Purpose

nag_nonpar_test_friedman (g08ae) performs the Friedman two-way analysis of variance by ranks on kk related samples of size nn.

Syntax

[fr, p, ifail] = g08ae(x, 'k', k, 'n', n)
[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:
Mark 22: k has been made optional
.

Description

The Friedman test investigates the score differences between kk matched samples of size nn, the scores in the iith sample being denoted by
xi1,xi2,,xin.
xi1,xi2,,xin.
(Thus the sample scores may be regarded as a two-way table with kk rows and nn columns.) The hypothesis under test, H0H0, often called the null hypothesis, is that the samples come from the same population, and this is to be tested against the alternative hypothesis H1H1 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, rijrij denoting the rank within column jj of the observation in row ii. Average ranks are assigned to tied scores.
(b) The ranks are summed over each row to give rank sums ti = j = 1nrijti=j=1nrij, for i = 1,2,,ki=1,2,,k.
(c) The Friedman test statistic FF is computed, where
k
F = 12/(nk(k + 1)){ti(1/2)n(k + 1)}2.
i = 1
F=12nk(k+1) i=1k{ti-12n(k+1)}2.
nag_nonpar_test_friedman (g08ae) returns the value of FF, and also an approximation, pp, to the significance of this value. (FF approximately follows a χk12χk-12 distribution, so large values of FF imply rejection of H0H0). H0H0 is rejected by a test of chosen size αα if p < αp<α. The approximation pp is acceptable unless k = 4k=4 and n < 5n<5, or k = 3k=3 and n < 10n<10, or k = 2k=2 and n < 20n<20; for k = 3​ or ​4k=3​ or ​4, tables should be consulted (e.g., Siegel (1956)); for k = 2k=2 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:     x(ldx,n) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxkldxk.
x(i,j)xij must be set to the value, xijxij, of observation jj in sample ii, for i = 1,2,,ki=1,2,,k and j = 1,2,,nj=1,2,,n.

Optional Input Parameters

1:     k – int64int32nag_int scalar
Default: The first dimension of the array x.
kk, the number of samples.
Constraint: k2k2.
2:     n – int64int32nag_int scalar
Default: The second dimension of the array x.
nn, the size of each sample.
Constraint: n1n1.

Input Parameters Omitted from the MATLAB Interface

ldx w1 w2

Output Parameters

1:     fr – double scalar
The value of the Friedman test statistic, FF.
2:     p – double scalar
The approximate significance, pp, of the Friedman test statistic.
3:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n < 1n<1.
  ifail = 2ifail=2
On entry,ldx < kldx<k.
  ifail = 3ifail=3
On entry,k1k1.

Accuracy

For estimates of the accuracy of the significance pp, see nag_stat_prob_chisq (g01ec). The χ2χ2 approximation is acceptable unless k = 4k=4 and n < 5n<5, or k = 3k=3 and n < 10n<10, or k = 2k=2 and n < 20n<20.

Further Comments

The time taken by nag_nonpar_test_friedman (g08ae) is approximately proportional to the product nknk.
If k = 2k=2, the Sign test (see nag_nonpar_test_sign (g08aa)) or Wilcoxon test (see nag_nonpar_test_wilcoxon (g08ag)) is more appropriate.

Example

function nag_nonpar_test_friedman_example
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];
[fr, p, ifail] = nag_nonpar_test_friedman(x)
 

fr =

    8.5833


p =

    0.0137


ifail =

                    0


function g08ae_example
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];
[fr, p, ifail] = g08ae(x)
 

fr =

    8.5833


p =

    0.0137


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013