PDF version (NAG web site
, 64-bit version, 64-bit 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
test statistic (calculated by
nag_nonpar_test_mwu (g08ah) and returned through the argument
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 test investigates the difference between two populations defined by the distribution functions and respectively. The data consist of two independent samples of size and , denoted by and , taken from the two populations.
The hypothesis under test,
, often called the null hypothesis, is that the two distributions are the same, that is
, and this is to be tested against an alternative hypothesis
which is
- : ; or
- : , i.e., the 's tend to be greater than the 's; or
- : , i.e., the 's tend to be less than the '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 argument
tail in
Arguments).
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 in favour of the alternative hypothesis : we have evidence to suggest that the location, of the distribution defined by , is less than the location, of the distribution defined by .
nag_nonpar_prob_mwu_noties (g08aj) returns the exact tail probability, , corresponding to , depending on the choice of alternative hypothesis, .
The value of can be used to perform a significance test on the null hypothesis against the alternative hypothesis . Let be the size of the significance test (that is, is the probability of rejecting when is true). If then the null hypothesis is rejected. Typically might be or .
References
Conover W J (1980) Practical Nonparametric Statistics Wiley
Harding E F (1983) An efficient minimal-storage 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) Non-parametric Statistics for the Behavioral Sciences McGraw–Hill
Parameters
Compulsory Input Parameters
- 1:
– int64int32nag_int scalar
-
The number of non-tied pairs, .
Constraint:
.
- 2:
– int64int32nag_int scalar
-
The size of the second sample, .
Constraint:
.
- 3:
– string (length ≥ 1)
-
Indicates the choice of tail probability, and hence the alternative hypothesis.
- A two tailed probability is calculated and the alternative hypothesis is .
- An upper tailed probability is calculated and the alternative hypothesis , i.e., the 's tend to be greater than the 's.
- A lower tailed probability is calculated and the alternative hypothesis , i.e., the 's tend to be less than the 's.
Constraint:
, or .
- 4:
– double scalar
-
, the value of the Mann–Whitney rank sum test statistic. This is the statistic returned through the argument
u by
nag_nonpar_test_mwu (g08ah).
Constraint:
.
Optional Input Parameters
None.
Output Parameters
- 1:
– double scalar
-
The exact tail probability,
, as specified by the argument
tail.
- 2:
– 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
The exact tail probability, , is computed to an accuracy of at least significant figures.
Further Comments
The time taken by nag_nonpar_prob_mwu_noties (g08aj) increases with and and the product .
Example
This example finds the Mann–Whitney test statistic, using
nag_nonpar_test_mwu (g08ah) for two independent samples of size
and
respectively. This is used to test the null hypothesis that the distributions of the two populations from which the samples were taken are the same against the alternative hypothesis that the distributions are different. The test statistic, the approximate normal statistic and the approximate two tail probability are printed.
nag_nonpar_prob_mwu_noties (g08aj) is then called to obtain the exact two tailed probability. The exact probability is also printed.
Open in the MATLAB editor:
g08aj_example
function g08aj_example
fprintf('g08aj example results\n\n');
x = [13.0 5.8 11.7 6.5 12.3 6.7 9.2 6.9 ...
10.0 7.3 16.0 7.0 10.5 8.5 9.0 7.5];
y = [17.0 6.2 10.1 8.0 15.3 8.2 15.0 9.6 ...
14.9 10.4 14.2 9.8 13.8 11.0 14.0 11.1 ...
12.9 11.6 12.8 12.0 13.1 12.4 11.9];
n1 = int64(numel(x));
n2 = int64(numel(y));
fprintf('Mann-Whitney U test\n\n');
fprintf('Sample size of group 1 = %5d\n', n1);
fprintf('Sample size of group 2 = %5d\n\n', n2);
fprintf('Data values\n');
fprintf('\n Group 1 ');
for j = 1:floor(n1/8)
i1 = (j-1)*8 + 1;
i2 = min(n1,i1+7);
fprintf('%5.1f',x(i1:i2));
fprintf('\n ');
end
fprintf('\n Group 2 ');
for j = 1:floor(n2/8)
i1 = (j-1)*8 + 1;
i2 = min(n2,i1+7);
fprintf('%5.1f',y(i1:i2));
fprintf('\n ');
end
tail = 'Lower-tail';
[u, unor, p, ties, ranks, ifail] = ...
g08ah(x, y, tail);
if ties
[pexact, ifail] = g08ak( ...
n1, n2, tail, ranks, u);
else
[pexact, ifail] = g08aj( ...
n1, n2, tail, u);
end
fprintf('\nTest statistic = %8.4f\n', u);
fprintf('Normalized test statistic = %8.4f\n', unor);
fprintf('Approx. tail probability = %8.4f\n\n', p);
if ties
fprintf('There are ties in the pooled sample\n\n');
else
fprintf('There are no ties in the pooled sample\n\n');
end
fprintf('Exact tail probability = %8.4f\n', pexact);
g08aj example results
Mann-Whitney U test
Sample size of group 1 = 16
Sample size of group 2 = 23
Data values
Group 1 13.0 5.8 11.7 6.5 12.3 6.7 9.2 6.9
10.0 7.3 16.0 7.0 10.5 8.5 9.0 7.5
Group 2 17.0 6.2 10.1 8.0 15.3 8.2 15.0 9.6
14.9 10.4 14.2 9.8 13.8 11.0 14.0 11.1
12.9 11.6 12.8 12.0 13.1 12.4 11.9
Test statistic = 86.0000
Normalized test statistic = -2.7838
Approx. tail probability = 0.0027
There are no ties in the pooled sample
Exact tail probability = 0.0022
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015