PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_univar_robust_2var_ci (g07eb)
Purpose
nag_univar_robust_2var_ci (g07eb) calculates a rank based (nonparametric) estimate and confidence interval for the difference in location between two independent populations.
Syntax
[
theta,
thetal,
thetau,
estcl,
ulower,
uupper,
ifail] = g07eb(
method,
x,
y,
clevel, 'n',
n, 'm',
m)
[
theta,
thetal,
thetau,
estcl,
ulower,
uupper,
ifail] = nag_univar_robust_2var_ci(
method,
x,
y,
clevel, 'n',
n, 'm',
m)
Description
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_univar_robust_2var_ci (g07eb) 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
Let
, for
, denote the
(ascendingly) ordered differences
, for
and
. Then
- 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
. Thus
is the value of the Mann–Whitney
statistic for the two independent samples
and
. Effectively
is a monotonically increasing step function of
with
The estimate
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
and
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
, for
and
. 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
and
initial estimates of the upper and lower confidence limits for the Mann–Whitney
statistic are found;
where
is the inverse cumulative Normal distribution function.
and
are rounded to the nearest integer values. These estimates are refined using an exact method, without taking ties into account, if
and
and a Normal approximation otherwise, to find
and
satisfying
and
The function
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.
References
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
Parameters
Compulsory Input Parameters
- 1:
– string (length ≥ 1)
-
Specifies the method to be used.
- The exact algorithm is used.
- The iterative algorithm is used.
Constraint:
or .
- 2:
– double array
-
The observations of the first sample,
, for .
- 3:
– double array
-
The observations of the second sample,
, for .
- 4:
– double scalar
-
The confidence interval required, ; e.g., for a confidence interval set .
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the size of the first sample.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the dimension of the array
y.
, the size of the second sample.
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The estimate of the difference in the location of the two populations, .
- 2:
– double scalar
-
The estimate of the lower limit of the confidence interval, .
- 3:
– double scalar
-
The estimate of the upper limit of the confidence interval, .
- 4:
– double scalar
-
An estimate of the actual percentage confidence of the interval found, as a proportion between .
- 5:
– double scalar
-
The value of the Mann–Whitney statistic corresponding to the lower confidence limit, .
- 6:
– double scalar
-
The value of the Mann–Whitney statistic corresponding to the upper confidence limit, .
- 7:
– 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:
Cases prefixed with W are classified as warnings and
do not generate an error of type NAG:error_n. See nag_issue_warnings.
-
-
On entry, | or , |
or | , |
or | , |
or | , |
or | . |
- W
-
Each sample consists of identical values. All estimates are set to the common difference between the samples.
- W
-
For at least one of the estimates , and , the underlying iterative algorithm (when ) failed to converge. This is an unlikely exit but the estimate should still be a reasonable approximation.
-
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
nag_univar_robust_2var_ci (g07eb) 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 .
Further Comments
The time taken increases with the sample sizes and .
Example
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.
Open in the MATLAB editor:
g07eb_example
function g07eb_example
fprintf('g07eb example results\n\n');
x = [-0.582; 0.157; -0.523; -0.769; 2.338; 1.664; -0.981; 1.549;
1.131; -0.460; -0.484; 1.932; 0.306; -0.602; -0.979; 0.132;
0.256; -0.094; 1.065; -1.084; -0.969; -0.524; 0.239; 1.512;
-0.782; -0.252; -1.163; 1.376; 1.674; 0.831; 1.478; -1.486;
-0.808; -0.429; -2.002; 0.482; -1.584; -0.105; 0.429; 0.568;
0.944; 2.558; -1.801; 0.242; 0.763; -0.461; -1.497; -1.353;
0.301; 1.941];
y = [ 1.995; 0.007; 0.997; 1.089; 2.004; 0.171; 0.294; 2.448;
0.214; 0.773; 2.960; 0.025; 0.638; 0.937; -0.568; -0.711;
0.931; 2.601; 1.121; -0.251; -0.050; 1.341; 2.282; 0.745;
1.633; 0.944; 2.370; 0.293; 0.895; 0.938; 0.199; 0.812;
1.253; 0.590; 1.522; -0.685; 1.259; 0.571; 1.579; 0.568;
0.381; 0.829; 0.277; 0.656; 2.497; 1.779; 1.922; -0.174;
2.132; 2.793; 0.102; 1.569; 1.267; 0.490; 0.077; 1.366;
0.056; 0.605; 0.628; 1.650; 0.104; 2.194; 2.869; -0.171;
-0.598; 2.134; 0.917; 0.630; 0.209; 1.328; 0.368; 0.756;
2.645; 1.161; 0.347; 0.920; 1.256; -0.052; 1.474; 0.510;
1.386; 3.550; 1.392; -0.358; 1.938; 1.727; -0.372; 0.911;
0.499; 0.066; 1.467; 1.898; 1.145; 0.501; 2.230; 0.212;
0.536; 1.690; 1.086; 0.494];
method = 'Approx';
clevel = 0.95;
[theta, thetal, thetau, estcl, ulower, uupper, ifail] = ...
g07eb(method, x, y, clevel);
fprintf(' Location estimator Confidence Interval\n\n');
fprintf('%13.4f%12s%7.4f,%7.4f )\n\n', theta, '(', thetal, thetau);
fprintf(' Corresponding Mann-Whitney statistics\n\n');
fprintf(' Lower : %8.2f\n', ulower);
fprintf(' Upper : %8.2f\n', uupper);
g07eb example results
Location estimator Confidence Interval
0.9505 ( 0.5650, 1.3050 )
Corresponding Mann-Whitney statistics
Lower : 2007.00
Upper : 2993.00
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015