NAG Library Function Document
nag_rank_ci_2var (g07ebc) calculates a rank based (nonparametric) estimate and confidence interval for the difference in location between two independent populations.
||nag_rank_ci_2var (Nag_RCIMethod method,
const double x,
const double y,
Consider two random samples from two populations which have the same continuous distribution except for a shift in the location. Let the random sample, , have distribution and the random sample, , have distribution .
nag_rank_ci_2var (g07ebc) finds a point estimate,
, of the difference in location
together with an associated confidence interval. The estimates are based on the ordered differences
. The estimate
is defined by
, denote the
(ascendingly) ordered differences
- if is odd, where ;
- if is even, where .
This estimator arises from inverting the two sample Mann–Whitney rank test statistic,
, for testing the hypothesis that
is the value of the Mann–Whitney
statistic for the two independent samples
is a monotonically increasing step function of
is the solution to the equation
; two methods are available for solving this equation. These methods avoid the computation of all the ordered differences
; this is because for large
both the storage requirements and the computation time would be high.
The first is an exact method based on a set partitioning procedure on the set of all differences
. This is adapted from the algorithm proposed by Monahan (1984)
for the computation of the Hodges–Lehmann estimator for a single population.
The second is an iterative algorithm, based on the Illinois method which is a modification of the regula falsi
method, see McKean and Ryan (1977)
. This algorithm has proved suitable for the function
which is asymptotically linear as a function of
The confidence interval limits are also based on the inversion of the Mann–Whitney test statistic.
Given a desired percentage for the confidence interval,
, expressed as a proportion between
initial estimates of the upper and lower confidence limits for the Mann–Whitney
statistic are found;
is the inverse cumulative Normal distribution function.
are rounded to the nearest integer values. These estimates are refined using an exact method, without taking ties into account, if
and a Normal approximation otherwise, to find
is a monotonically increasing step function. It is the number of times a score in the second sample,
, precedes a score in the first sample,
, where we only count a half if a score in the second sample actually equals a score in the first.
Let ; then . This is the largest value such that .
Let ; then . This is the smallest value such that .
As in the case of , these equations may be solved using either the exact or iterative methods to find the values and .
Then is the confidence interval for . The confidence interval is thus defined by those values of such that the null hypothesis, , is not rejected by the Mann–Whitney two sample rank test at the level.
Lehmann E L (1975) Nonparametrics: Statistical Methods Based on Ranks Holden–Day
McKean J W and Ryan T A (1977) Algorithm 516: An algorithm for obtaining confidence intervals and point estimates based on ranks in the two-sample location problem ACM Trans. Math. Software 10 183–185
Monahan J F (1984) Algorithm 616: Fast computation of the Hodges–Lehman location estimator ACM Trans. Math. Software 10 265–270
method – Nag_RCIMethodInput
: specifies the method to be used.
- The exact algorithm is used.
- The iterative algorithm is used.
n – IntegerInput
On entry: , the size of the first sample.
x[n] – const doubleInput
On entry: the observations of the first sample,
, for .
m – IntegerInput
On entry: , the size of the second sample.
y[m] – const doubleInput
On entry: the observations of the second sample,
, for .
clevel – doubleInput
On entry: the confidence interval required, ; e.g., for a confidence interval set .
theta – double *Output
On exit: the estimate of the difference in the location of the two populations, .
thetal – double *Output
On exit: the estimate of the lower limit of the confidence interval, .
thetau – double *Output
On exit: the estimate of the upper limit of the confidence interval, .
estcl – double *Output
On exit: an estimate of the actual percentage confidence of the interval found, as a proportion between .
ulower – double *Output
On exit: the value of the Mann–Whitney statistic corresponding to the lower confidence limit, .
uupper – double *Output
On exit: the value of the Mann–Whitney statistic corresponding to the upper confidence limit, .
fail – NagError *Input/Output
The NAG error argument (see Section 3.6
in the Essential Introduction).
6 Error Indicators and Warnings
Dynamic memory allocation failed.
On entry, argument had an illegal value.
Warning. The iterative procedure to find an estimate of the lower confidence limit has not converged in iterations.
Warning. The iterative procedure to find an estimate of Theta has not converged in iterations.
Warning. The iterative procedure to find an estimate of the upper confidence limit has not converged in iterations.
On entry, .
On entry, .
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG
On entry, clevel
is out of range:
Not enough information to compute an interval estimate since each sample has identical values. The common difference is returned in theta
nag_rank_ci_2var (g07ebc) should return results accurate to five significant figures in the width of the confidence interval, that is the error for any one of the three estimates should be less than .
8 Parallelism and Performance
nag_rank_ci_2var (g07ebc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_rank_ci_2var (g07ebc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the Users' Note
for your implementation for any additional implementation-specific information.
The time taken increases with the sample sizes and .
The following program calculates a 95% confidence interval for the difference in location between the two populations from which the two samples of sizes and are drawn respectively.
10.1 Program Text
Program Text (g07ebce.c)
10.2 Program Data
Program Data (g07ebce.d)
10.3 Program Results
Program Results (g07ebce.r)