PDF version (NAG web site
, 64bit version, 64bit version)
NAG Toolbox: nag_nonpar_prob_mwu_noties (g08aj)
Purpose
nag_nonpar_prob_mwu_noties (g08aj) calculates the exact tail probability for the Mann–Whitney rank sum test statistic for the case where there are no ties in the two samples pooled together.
Syntax
Description
nag_nonpar_prob_mwu_noties (g08aj) computes the exact tail probability for the Mann–Whitney
U$U$ test statistic (calculated by
nag_nonpar_test_mwu (g08ah) and returned through the parameter
u) using a method based on an algorithm developed by
Harding (1983), and presented by
Neumann (1988), for the case where there are no ties in the pooled sample.
The Mann–Whitney U$U$ test investigates the difference between two populations defined by the distribution functions F(x)$F\left(x\right)$ and G(y)$G\left(y\right)$ respectively. The data consist of two independent samples of size n_{1}${n}_{1}$ and n_{2}${n}_{2}$, denoted by x_{1},x_{2}, … ,x_{n1}${x}_{1},{x}_{2},\dots ,{x}_{{n}_{1}}$ and y_{1},y_{2}, … ,y_{n2}${y}_{1},{y}_{2},\dots ,{y}_{{n}_{2}}$, taken from the two populations.
The hypothesis under test,
H_{0}${H}_{0}$, often called the null hypothesis, is that the two distributions are the same, that is
F(x) = G(x)$F\left(x\right)=G\left(x\right)$, and this is to be tested against an alternative hypothesis
H_{1}${H}_{1}$ which is
 H_{1}${H}_{1}$: F(x) ≠ G(y)$F\left(x\right)\ne G\left(y\right)$; or
 H_{1}${H}_{1}$: F(x) < G(y)$F\left(x\right)<G\left(y\right)$, i.e., the x$x$'s tend to be greater than the y$y$'s; or
 H_{1}${H}_{1}$: F(x) > G(y)$F\left(x\right)>G\left(y\right)$, i.e., the x$x$'s tend to be less than the y$y$'s,
using a two tailed, upper tailed or lower tailed probability respectively. You select the alternative hypothesis by choosing the appropriate tail probability to be computed (see the description of parameter
tail in
Section [Parameters]).
Note that when using this test to test for differences in the distributions one is primarily detecting differences in the location of the two distributions. That is to say, if we reject the null hypothesis H_{0}${H}_{0}$ in favour of the alternative hypothesis H_{1}${H}_{1}$: F(x) > G(y)$F\left(x\right)>G\left(y\right)$ we have evidence to suggest that the location, of the distribution defined by F(x)$F\left(x\right)$, is less than the location, of the distribution defined by G(y)$G\left(y\right)$.
nag_nonpar_prob_mwu_noties (g08aj) returns the exact tail probability, p$p$, corresponding to U$U$, depending on the choice of alternative hypothesis, H_{1}${H}_{1}$.
The value of p$p$ can be used to perform a significance test on the null hypothesis H_{0}${H}_{0}$ against the alternative hypothesis H_{1}${H}_{1}$. Let α$\alpha $ be the size of the significance test (that is, α$\alpha $ is the probability of rejecting H_{0}${H}_{0}$ when H_{0}${H}_{0}$ is true). If p < α$p<\alpha $ then the null hypothesis is rejected. Typically α$\alpha $ might be 0.05$0.05$ or 0.01$0.01$.
References
Conover W J (1980) Practical Nonparametric Statistics Wiley
Harding E F (1983) An efficient minimalstorage procedure for calculating the Mann–Whitney U, generalised U and similar distributions Appl. Statist. 33 1–6
Neumann N (1988) Some procedures for calculating the distributions of elementary nonparametric teststatistics Statistical Software Newsletter 14(3) 120–126
Siegel S (1956) Nonparametric Statistics for the Behavioral Sciences McGraw–Hill
Parameters
Compulsory Input Parameters
 1:
n1 – int64int32nag_int scalar
The number of nontied pairs, n_{1}${\mathit{n}}_{1}$.
Constraint:
n1 ≥ 1${\mathbf{n1}}\ge 1$.
 2:
n2 – int64int32nag_int scalar
The size of the second sample, n_{2}${\mathit{n}}_{2}$.
Constraint:
n2 ≥ 1${\mathbf{n2}}\ge 1$.
 3:
tail – string (length ≥ 1)
Indicates the choice of tail probability, and hence the alternative hypothesis.
 tail = 'T'${\mathbf{tail}}=\text{'T'}$
 A two tailed probability is calculated and the alternative hypothesis is H_{1} : F(x) ≠ G(y)${H}_{1}:F\left(x\right)\ne G\left(y\right)$.
 tail = 'U'${\mathbf{tail}}=\text{'U'}$
 An upper tailed probability is calculated and the alternative hypothesis H_{1} : F(x) < G(y)${H}_{1}:F\left(x\right)<G\left(y\right)$, i.e., the x$x$'s tend to be greater than the y$y$'s.
 tail = 'L'${\mathbf{tail}}=\text{'L'}$
 A lower tailed probability is calculated and the alternative hypothesis H_{1} : F(x) > G(y)${H}_{1}:F\left(x\right)>G\left(y\right)$, i.e., the x$x$'s tend to be less than the y$y$'s.
Constraint:
tail = 'T'${\mathbf{tail}}=\text{'T'}$,
'U'$\text{'U'}$ or
'L'$\text{'L'}$.
 4:
u – double scalar
U$U$, the value of the Mann–Whitney rank sum test statistic. This is the statistic returned through the parameter
u by
nag_nonpar_test_mwu (g08ah).
Constraint:
u ≥ 0.0${\mathbf{u}}\ge 0.0$.
Optional Input Parameters
None.
Input Parameters Omitted from the MATLAB Interface
 wrk lwrk
Output Parameters
 1:
p – double scalar
The exact tail probability,
p$p$, as specified by the parameter
tail.
 2:
ifail – int64int32nag_int scalar
ifail = 0${\mathrm{ifail}}={\mathbf{0}}$ unless the function detects an error (see
[Error Indicators and Warnings]).
Error Indicators and Warnings
Errors or warnings detected by the function:
 ifail = 1${\mathbf{ifail}}=1$

On entry,  n1 < 1${\mathbf{n1}}<1$, 
or  n2 < 1${\mathbf{n2}}<1$. 
 ifail = 2${\mathbf{ifail}}=2$

On entry,  tail ≠ 'T'${\mathbf{tail}}\ne \text{'T'}$, 'U'$\text{'U'}$ or 'L'$\text{'L'}$. 
 ifail = 3${\mathbf{ifail}}=3$

On entry,  u < 0.0${\mathbf{u}}<0.0$. 
 ifail = 4${\mathbf{ifail}}=4$
On entry,  lwrk < (n1 × n2) / 2 + 1$\mathit{lwrk}<({\mathbf{n1}}\times {\mathbf{n2}})/2+1$. 
Accuracy
The exact tail probability, p$p$, is computed to an accuracy of at least 4$4$ significant figures.
Further Comments
The time taken by nag_nonpar_prob_mwu_noties (g08aj) increases with n_{1}${n}_{1}$ and n_{2}${n}_{2}$ and the product n_{1}n_{2}${n}_{1}{n}_{2}$.
Example
Open in the MATLAB editor:
nag_nonpar_prob_mwu_noties_example
function nag_nonpar_prob_mwu_noties_example
n1 = int64(16);
n2 = int64(23);
tail = 'Lowertail';
u = 86;
[p, ifail] = nag_nonpar_prob_mwu_noties(n1, n2, tail, u)
p =
0.0022
ifail =
0
Open in the MATLAB editor:
g08aj_example
function g08aj_example
n1 = int64(16);
n2 = int64(23);
tail = 'Lowertail';
u = 86;
[p, ifail] = g08aj(n1, n2, tail, u)
p =
0.0022
ifail =
0
PDF version (NAG web site
, 64bit version, 64bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013