Mood's and David's tests investigate the difference between the dispersions of two independent samples of sizes
${n}_{1}$ and
${n}_{2}$, denoted by
and
The hypothesis under test,
${H}_{0}$, often called the null hypothesis, is that the dispersion difference is zero, and this is to be tested against a one or twosided alternative hypothesis
${H}_{1}$ (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.
The returned value
$p$ (
$={p}_{v}$ or
${p}_{w}$) can be used to perform a significance test, against various alternative hypotheses
${H}_{1}$, as follows.

(i)${H}_{1}$: dispersions are unequal. ${H}_{0}$ is rejected if $2\times \mathrm{min}\phantom{\rule{0.125em}{0ex}}(p,1p)<\alpha $.

(ii)${H}_{1}$: dispersion of sample $1>\text{}$ dispersion of sample $2$. ${H}_{0}$ is rejected if $1p<\alpha $.

(iii)${H}_{1}$: dispersion of sample $2>\text{}$ dispersion of sample $1$. ${H}_{0}$ is rejected if $p<\alpha $.

1:
$\mathbf{x}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) array
Input

On entry: the first
${n}_{1}$ elements of
x must be set to the data values in the first sample, and the next
${n}_{2}$ (
$\text{}={\mathbf{n}}{n}_{1}$) elements to the data values in the second sample.

2:
$\mathbf{n}$ – Integer
Input

On entry: the total of the two sample sizes, $n$ ($\text{}={n}_{1}+{n}_{2}$).
Constraint:
${\mathbf{n}}>2$.

3:
$\mathbf{n1}$ – Integer
Input

On entry: the size of the first sample, ${n}_{1}$.
Constraint:
$1<{\mathbf{n1}}<{\mathbf{n}}$.

4:
$\mathbf{r}\left({\mathbf{n}}\right)$ – Real (Kind=nag_wp) array
Output

On exit: the ranks
${r}_{\mathit{i}}$, assigned to the data values ${x}_{\mathit{i}}$, for $\mathit{i}=1,2,\dots ,n$.

5:
$\mathbf{itest}$ – Integer
Input

On entry: the test(s) to be carried out.
 ${\mathbf{itest}}=0$
 Both Mood's and David's tests.
 ${\mathbf{itest}}=1$
 David's test only.
 ${\mathbf{itest}}=2$
 Mood's test only.
Constraint:
${\mathbf{itest}}=0$, $1$ or $2$.

6:
$\mathbf{w}$ – Real (Kind=nag_wp)
Output

On exit: Mood's test statistic, $W$, if requested.

7:
$\mathbf{v}$ – Real (Kind=nag_wp)
Output

On exit: David's test statistic, $V$, if requested.

8:
$\mathbf{pw}$ – Real (Kind=nag_wp)
Output

On exit: the lower tail probability, ${p}_{w}$, corresponding to the value of $W$, if Mood's test was requested.

9:
$\mathbf{pv}$ – Real (Kind=nag_wp)
Output

On exit: the lower tail probability, ${p}_{v}$, corresponding to the value of $V$, if David's test was requested.

10:
$\mathbf{ifail}$ – Integer
Input/Output

On entry:
ifail must be set to
$0$,
$1$ or
$1$ to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of $0$ causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of $1$ means that an error message is printed while a value of $1$ means that it is not.
If halting is not appropriate, the value
$1$ or
$1$ is recommended. If message printing is undesirable, then the value
$1$ is recommended. Otherwise, the value
$0$ is recommended.
When the value $\mathbf{1}$ or $\mathbf{1}$ is used it is essential to test the value of ifail on exit.
On exit:
${\mathbf{ifail}}={\mathbf{0}}$ unless the routine detects an error or a warning has been flagged (see
Section 6).
If on entry
${\mathbf{ifail}}=0$ or
$1$, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
All computations are believed to be stable. The statistics $V$ and $W$ should be accurate enough for all practical uses.
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.