naginterfaces.library.nonpar.test_​mooddavid

naginterfaces.library.nonpar.test_mooddavid(x, n1, itest)[source]

test_mooddavid performs Mood’s and David’s tests for dispersion differences between two independent samples of possibly unequal size.

For full information please refer to the NAG Library document for g08ba

https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g08/g08baf.html

Parameters
xfloat, array-like, shape

The first elements of must be set to the data values in the first sample, and the next () elements to the data values in the second sample.

n1int

The size of the first sample, .

itestint

The test(s) to be carried out.

Both Mood’s and David’s tests.

David’s test only.

Mood’s test only.

Returns
rfloat, ndarray, shape

The ranks , assigned to the data values , for .

wfloat

Mood’s test statistic, , if requested.

vfloat

David’s test statistic, , if requested.

pwfloat

The lower tail probability, , corresponding to the value of , if Mood’s test was requested.

pvfloat

The lower tail probability, , corresponding to the value of , if David’s test was requested.

Raises
NagValueError
(errno )

On entry, .

Constraint: .

(errno )

On entry, and .

Constraint: .

(errno )

On entry, .

Constraint: , or .

Notes

No equivalent traditional C interface for this routine exists in the NAG Library.

Mood’s and David’s tests investigate the difference between the dispersions of two independent samples of sizes and , denoted by

and

The hypothesis under test, , 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 (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 be denoted by , for .

  1. Mood’s test.

    The test statistic is found.

    is the sum of squared deviations from the average rank in the pooled sample. For large , approaches normality, and so an approximation, , to the probability of observing not greater than the computed value, may be found.

    test_mooddavid returns and if Mood’s test is selected.

  2. 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 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

    where

    For large , approaches normality, enabling an approximate probability to be computed, similarly to .

    test_mooddavid returns and 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 when is true; typically is a small quantity such as or ).

The returned value ( or ) can be used to perform a significance test, against various alternative hypotheses , as follows.

  1. : dispersions are unequal. is rejected if .

  2. : dispersion of sample dispersion of sample . is rejected if .

  3. : dispersion of sample dispersion of sample . is rejected if .

References

Cooper, B E, 1975, Statistics for Experimentalists, Pergamon Press