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_mooddavid (g08ba)

Purpose

nag_nonpar_test_mooddavid (g08ba) performs Mood's and David's tests for dispersion differences between two independent samples of possibly unequal size.

Syntax

[r, w, v, pw, pv, ifail] = g08ba(x, n1, itest, 'n', n)
[r, w, v, pw, pv, ifail] = nag_nonpar_test_mooddavid(x, n1, itest, 'n', n)

Description

Mood's and David's tests investigate the difference between the dispersions of two independent samples of sizes n1n1 and n2n2, denoted by
x1,x2,,xn1
x1,x2,,xn1
and
xn1 + 1,xn1 + 2,,xn,   n = n1 + n2.
xn1+ 1,xn1+ 2,,xn,   n=n1+n2.
The hypothesis under test, H0H0, often called the null hypothesis, is that the dispersion difference is zero, and this is to be tested against a one- or two-sided alternative hypothesis H1H1 (see below).
Both tests are based on the rankings of the sample members within the pooled sample formed by combining both samples. If there is some difference in dispersion, more of the extreme ranks will tend to be found in one sample than in the other.
Let the rank of xixi be denoted by riri, for i = 1,2,,ni=1,2,,n.
(a) Mood's test.
The test statistic W = i = 1n1 (ri(n + 1)/2)2W=i=1n1 (ri- n+12) 2 is found.
WW is the sum of squared deviations from the average rank in the pooled sample. For large nn, WW approaches normality, and so an approximation, pwpw, to the probability of observing WW not greater than the computed value, may be found.
nag_nonpar_test_mooddavid (g08ba) returns WW and pwpw if Mood's test is selected.
(b) David's test.
The disadvantage of Mood's test is that it assumes that the means of the two samples are equal. If this assumption is unjustified a high value of WW could merely reflect the difference in means. David's test reduces this effect by using the variance of the ranks of the first sample about their mean rank, rather than the overall mean rank.
The test statistic for David's test is
n1
V = 1/(n11)(rir)2
i = 1
V=1n1-1 i=1n1 (ri-r-) 2
where
r = (i = 1n1ri)/(n1).
r-=i= 1n1rin1.
For large nn, VV approaches normality, enabling an approximate probability pvpv to be computed, similarly to pwpw.
nag_nonpar_test_mooddavid (g08ba) returns VV and pvpv if David's test is selected.
Suppose that a significance test of a chosen size αα is to be performed (i.e., αα is the probability of rejecting H0H0 when H0H0 is true; typically αα is a small quantity such as 0.050.05 or 0.010.01).
The returned value pp ( = pv=pv or pwpw) can be used to perform a significance test, against various alternative hypotheses H1H1, as follows.
(i) H1H1: dispersions are unequal. H0H0 is rejected if 2 × min (p,1p) < α 2 × min(p,1-p) < α .
(ii) H1H1: dispersion of sample 1 > 1> dispersion of sample 22. H0H0 is rejected if 1p < α1-p<α.
(iii) H1H1: dispersion of sample 2 > 2> dispersion of sample 11. H0H0 is rejected if p < αp<α.

References

Cooper B E (1975) Statistics for Experimentalists Pergamon Press

Parameters

Compulsory Input Parameters

1:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n > 2n>2.
The first n1n1 elements of x must be set to the data values in the first sample, and the next n2n2 ( = nn1=n-n1) elements to the data values in the second sample.
2:     n1 – int64int32nag_int scalar
The size of the first sample, n1n1.
Constraint: 1 < n1 < n1<n1<n.
3:     itest – int64int32nag_int scalar
The test(s) to be carried out.
itest = 0itest=0
Both Mood's and David's tests.
itest = 1itest=1
David's test only.
itest = 2itest=2
Mood's test only.
Constraint: itest = 0itest=0, 11 or 22.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
The total of the two sample sizes, nn ( = n1 + n2=n1+n2).
Constraint: n > 2n>2.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     r(n) – double array
The ranks riri, assigned to the data values xixi, for i = 1,2,,ni=1,2,,n.
2:     w – double scalar
Mood's test statistic, WW, if requested.
3:     v – double scalar
David's test statistic, VV, if requested.
4:     pw – double scalar
The lower tail probability, pwpw, corresponding to the value of WW, if Mood's test was requested.
5:     pv – double scalar
The lower tail probability, pvpv, corresponding to the value of VV, if David's test was requested.
6:     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,n2n2.
  ifail = 2ifail=2
On entry,n11n11,
orn1nn1n.
  ifail = 3ifail=3
On entry,itest < 0itest<0,
oritest > 2itest>2.

Accuracy

All computations are believed to be stable. The statistics VV and WW should be accurate enough for all practical uses.

Further Comments

The time taken by nag_nonpar_test_mooddavid (g08ba) is small, and increases with nn.

Example

function nag_nonpar_test_mooddavid_example
x = [6;
     9;
     12;
     4;
     10;
     11;
     8;
     1;
     3;
     7;
     2;
     5];
n1 = int64(6);
itest = int64(0);
[r, w, v, pw, pv, ifail] = nag_nonpar_test_mooddavid(x, n1, itest)
 

r =

     6
     9
    12
     4
    10
    11
     8
     1
     3
     7
     2
     5


w =

   75.5000


v =

    9.4667


pw =

    0.5830


pv =

    0.1986


ifail =

                    0


function g08ba_example
x = [6;
     9;
     12;
     4;
     10;
     11;
     8;
     1;
     3;
     7;
     2;
     5];
n1 = int64(6);
itest = int64(0);
[r, w, v, pw, pv, ifail] = g08ba(x, n1, itest)
 

r =

     6
     9
    12
     4
    10
    11
     8
     1
     3
     7
     2
     5


w =

   75.5000


v =

    9.4667


pw =

    0.5830


pv =

    0.1986


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