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_prob_mwu_ties (g08ak)

Purpose

nag_nonpar_prob_mwu_ties (g08ak) calculates the exact tail probability for the Mann–Whitney rank sum test statistic for the case where there are ties in the two samples pooled together.

Syntax

[p, ifail] = g08ak(n1, n2, tail, ranks, u)
[p, ifail] = nag_nonpar_prob_mwu_ties(n1, n2, tail, ranks, u)

Description

nag_nonpar_prob_mwu_ties (g08ak) computes the exact tail probability for the Mann–Whitney UU test statistic (calculated by nag_nonpar_test_mwu (g08ah) and returned through the parameter u) using a method based on an algorithm developed by Neumann (1988), for the case where there are ties in the pooled sample.
The Mann–Whitney UU test investigates the difference between two populations defined by the distribution functions F(x)F(x) and G(y)G(y) respectively. The data consist of two independent samples of size n1n1 and n2n2, denoted by x1,x2,,xn1x1,x2,,xn1 and y1,y2,,yn2y1,y2,,yn2, taken from the two populations.
The hypothesis under test, H0H0, often called the null hypothesis, is that the two distributions are the same, that is F(x) = G(x)F(x)=G(x), and this is to be tested against an alternative hypothesis H1H1 which is 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 H0H0 in favour of the alternative hypothesis H1H1: F(x) > G(y)F(x)>G(y) we have evidence to suggest that the location, of the distribution defined by F(x)F(x), is less than the location of the distribution defined by G(y)G(y).
nag_nonpar_prob_mwu_ties (g08ak) returns the exact tail probability, pp, corresponding to UU, depending on the choice of alternative hypothesis, H1H1.
The value of pp can be used to perform a significance test on the null hypothesis H0H0 against the alternative hypothesis H1H1. Let αα be the size of the significance test (that is αα is the probability of rejecting H0H0 when H0H0 is true). If p < αp<α then the null hypothesis is rejected. Typically αα might be 0.050.05 or 0.010.01.

References

Conover W J (1980) Practical Nonparametric Statistics Wiley
Neumann N (1988) Some procedures for calculating the distributions of elementary nonparametric teststatistics Statistical Software Newsletter 14(3) 120–126
Siegel S (1956) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill

Parameters

Compulsory Input Parameters

1:     n1 – int64int32nag_int scalar
The number of non-tied pairs, n1n1.
Constraint: n11n11.
2:     n2 – int64int32nag_int scalar
The size of the second sample, n2n2.
Constraint: n21n21.
3:     tail – string (length ≥ 1)
Indicates the choice of tail probability, and hence the alternative hypothesis.
tail = 'T'tail='T'
A two tailed probability is calculated and the alternative hypothesis is H1 : F(x)G(y)H1:F(x)G(y).
tail = 'U'tail='U'
An upper tailed probability is calculated and the alternative hypothesis H1 : F(x) < G(y)H1:F(x)<G(y), i.e., the xx's tend to be greater than the yy's.
tail = 'L'tail='L'
A lower tailed probability is calculated and the alternative hypothesis H1 : F(x) > G(y)H1:F(x)>G(y), i.e., the xx's tend to be less than the yy's.
Constraint: tail = 'T'tail='T', 'U''U' or 'L''L'.
4:     ranks(n1 + n2n1+n2) – double array
The ranks of the pooled sample. These ranks are output in the array ranks by nag_nonpar_test_mwu (g08ah) and should not be altered in any way if you are using the same n1n1, n2n2 and uu as used in nag_nonpar_test_mwu (g08ah).
5:     u – double scalar
UU, 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: u0.0u0.0.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

wrk lwrk iwrk

Output Parameters

1:     p – double scalar
The tail probability, pp, as specified by the parameter tail.
2:     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,n1 < 1n1<1,
orn2 < 1n2<1.
  ifail = 2ifail=2
On entry,tail'T'tail'T', 'U''U' or 'L''L'.
  ifail = 3ifail=3
On entry,u < 0.0u<0.0.
  ifail = 4ifail=4
On entry,lwrk is too small.

Accuracy

The exact tail probability, pp, is computed to an accuracy of at least 44 significant figures.

Further Comments

The time taken by nag_nonpar_prob_mwu_ties (g08ak) increases with n1n1 and n2n2 and the product n1n2n1n2. Note that the amount of workspace required becomes very large for even moderate sizes of n1n1 and n2n2.

Example

function nag_nonpar_prob_mwu_ties_example
n1 = int64(16);
n2 = int64(23);
tail = 'Lower-tail';
ranks = [29.5;
     1.5;
     24.5;
     5;
     24.5;
     5;
     16;
     5;
     16;
     5;
     38;
     5;
     16;
     9.5;
     12;
     9.5;
     39;
     1.5;
     16;
     9.5;
     36;
     9.5;
     36;
     16;
     36;
     16;
     33;
     16;
     33;
     20.5;
     33;
     20.5;
     29.5;
     24.5;
     29.5;
     24.5;
     29.5;
     24.5;
     24.5];
u = 86;
[p, ifail] = nag_nonpar_prob_mwu_ties(n1, n2, tail, ranks, u)
 

p =

    0.0020


ifail =

                    0


function g08ak_example
n1 = int64(16);
n2 = int64(23);
tail = 'Lower-tail';
ranks = [29.5;
     1.5;
     24.5;
     5;
     24.5;
     5;
     16;
     5;
     16;
     5;
     38;
     5;
     16;
     9.5;
     12;
     9.5;
     39;
     1.5;
     16;
     9.5;
     36;
     9.5;
     36;
     16;
     36;
     16;
     33;
     16;
     33;
     20.5;
     33;
     20.5;
     29.5;
     24.5;
     29.5;
     24.5;
     29.5;
     24.5;
     24.5];
u = 86;
[p, ifail] = g08ak(n1, n2, tail, ranks, u)
 

p =

    0.0020


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