NAG FL Interface
g08ajf (prob_mwu_noties)
1
Purpose
g08ajf 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.
2
Specification
Fortran Interface
Integer, Intent (In) |
:: |
n1, n2, lwrk |
Integer, Intent (Inout) |
:: |
ifail |
Real (Kind=nag_wp), Intent (In) |
:: |
u |
Real (Kind=nag_wp), Intent (Out) |
:: |
p, wrk(lwrk) |
Character (1), Intent (In) |
:: |
tail |
|
C Header Interface
#include <nag.h>
void |
g08ajf_ (const Integer *n1, const Integer *n2, const char *tail, const double *u, double *p, double wrk[], const Integer *lwrk, Integer *ifail, const Charlen length_tail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g08ajf_ (const Integer &n1, const Integer &n2, const char *tail, const double &u, double &p, double wrk[], const Integer &lwrk, Integer &ifail, const Charlen length_tail) |
}
|
The routine may be called by the names g08ajf or nagf_nonpar_prob_mwu_noties.
3
Description
g08ajf computes the exact tail probability for the Mann–Whitney
test statistic (calculated by
g08ahf 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
Section 5).
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 .
g08ajf 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 .
4
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
5
Arguments
-
1:
– Integer
Input
-
On entry: the number of non-tied pairs, .
Constraint:
.
-
2:
– Integer
Input
-
On entry: the size of the second sample, .
Constraint:
.
-
3:
– Character(1)
Input
-
On entry: 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:
– Real (Kind=nag_wp)
Input
-
On entry:
, the value of the Mann–Whitney rank sum test statistic. This is the statistic returned through the argument
u by
g08ahf.
Constraint:
.
-
5:
– Real (Kind=nag_wp)
Output
-
On exit: the exact tail probability,
, as specified by the argument
tail.
-
6:
– Real (Kind=nag_wp) array
Workspace
-
7:
– Integer
Input
-
On entry: the dimension of the array
wrk as declared in the (sub)program from which
g08ajf is called.
Constraint:
.
-
8:
– Integer
Input/Output
-
On entry:
ifail must be set to
,
or
to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value
or
is recommended. If message printing is undesirable, then the value
is recommended. Otherwise, the value
is recommended.
When the value or is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, .
Constraint: .
-
On entry, .
Constraint: , or .
-
On entry, .
Constraint: .
-
On entry, and the minimum workspace is .
Constraint: .
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See
Section 9 in the Introduction to the NAG Library FL Interface for further information.
7
Accuracy
The exact tail probability, , is computed to an accuracy of at least significant figures.
8
Parallelism and Performance
g08ajf is not threaded in any implementation.
The time taken by g08ajf increases with and and the product .
10
Example
This example finds the Mann–Whitney test statistic, using
g08ahf 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.
g08ajf is then called to obtain the exact two tailed probability. The exact probability is also printed.
10.1
Program Text
10.2
Program Data
10.3
Program Results