PDF version (NAG web site
, 64-bit version, 64-bit version)
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
Description
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
.
(a) |
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.
nag_nonpar_test_mooddavid (g08ba) returns and 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 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 .
nag_nonpar_test_mooddavid (g08ba) 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.
(i) |
: dispersions are unequal. is rejected if . |
(ii) |
: dispersion of sample dispersion of sample . is rejected if . |
(iii) |
: dispersion of sample dispersion of sample . is rejected if . |
References
Cooper B E (1975) Statistics for Experimentalists Pergamon Press
Parameters
Compulsory Input Parameters
- 1:
– double array
-
The first
elements of
x must be set to the data values in the first sample, and the next
(
) elements to the data values in the second sample.
- 2:
– int64int32nag_int scalar
-
The size of the first sample, .
Constraint:
.
- 3:
– int64int32nag_int scalar
-
The test(s) to be carried out.
- Both Mood's and David's tests.
- David's test only.
- Mood's test only.
Constraint:
, or .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
The total of the two sample sizes, ().
Constraint:
.
Output Parameters
- 1:
– double array
-
The ranks
, assigned to the data values , for .
- 2:
– double scalar
-
Mood's test statistic, , if requested.
- 3:
– double scalar
-
David's test statistic, , if requested.
- 4:
– double scalar
-
The lower tail probability, , corresponding to the value of , if Mood's test was requested.
- 5:
– double scalar
-
The lower tail probability, , corresponding to the value of , if David's test was requested.
- 6:
– 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:
-
-
-
-
-
-
On entry, | , |
or | . |
-
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
All computations are believed to be stable. The statistics and should be accurate enough for all practical uses.
Further Comments
The time taken by nag_nonpar_test_mooddavid (g08ba) is small, and increases with .
Example
This example is taken from page 280 of
Cooper (1975). The data consists of two samples of six observations each. Both Mood's and David's test statistics and significances are computed. Note that Mood's statistic is inflated owing to the difference in location of the two samples, the median ranks differing by a factor of two.
Open in the MATLAB editor:
g08ba_example
function g08ba_example
fprintf('g08ba example results\n\n');
x = [6; 9; 12; 4; 10; 11; 8; 1; 3; 7; 2; 5];
n1 = int64(6);
fprintf('Mood''s test and David''s test\n\n');
fprintf('Data values\n\n');
fprintf('Group 1\n');
fprintf('%4.0f',x(1:n1));
fprintf('\n\nGroup 2\n');
fprintf('%4.0f',x(n1+1:end));
fprintf('\n\n');
itest = int64(0);
[r, w, v, pw, pv, ifail] = g08ba( ...
x, n1, itest);
fprintf(' Mood''s measure = %8.3f Significance = %8.4f\n', w, pw);
fprintf(' David''s measure = %8.3f Significance = %8.4f\n', v, pv);
g08ba example results
Mood's test and David's test
Data values
Group 1
6 9 12 4 10 11
Group 2
8 1 3 7 2 5
Mood's measure = 75.500 Significance = 0.5830
David's measure = 9.467 Significance = 0.1986
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015