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_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, x = (x1,x2,,xn)Tx=(x1,x2,,xn)T, have distribution F(x)F(x) and the random sample, y = (y1,y2,,ym)Ty=(y1,y2,,ym)T, have distribution F(xθ)F(x-θ).
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 yjxiyj-xi. The estimate θ̂θ^ is defined by
θ̂ = median {yjxi,  i = 1,2,,n;j = 1,2,,m} .
θ^ = median { yj-xi ,   i=1,2,,n ; j=1,2,,m } .
Let dkdk, for k = 1,2,,nmk=1,2,,nm, denote the nmnm (ascendingly) ordered differences yjxiyj-xi, for i = 1,2,,ni=1,2,,n and j = 1,2,,mj=1,2,,m. Then
This estimator arises from inverting the two sample Mann–Whitney rank test statistic, U(θ0)U(θ0), for testing the hypothesis that θ = θ0θ=θ0. Thus U(θ0)U(θ0) is the value of the Mann–Whitney UU statistic for the two independent samples {(xi + θ0), for ​i = 1,2,,n} { ( xi + θ0 ) , for ​ i=1,2,,n }  and {yj, for ​j = 1,2,,m} { yj , for ​ j=1,2,,m} . Effectively U(θ0)U(θ0) is a monotonically increasing step function of θ0θ0 with
mean ​(U) = μ = (nm)/2,
var(U) = σ2(nm(n + m + 1))/12.
mean ​(U)=μ= nm2, var(U)=σ2 nm(n+m+1)12.
The estimate θ̂θ^ is the solution to the equation U(θ̂) = μU(θ^)=μ; two methods are available for solving this equation. These methods avoid the computation of all the ordered differences dkdk; this is because for large nn and mm 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 yjxiyj-xi, for i = 1,2,,ni=1,2,,n and j = 1,2,,mj=1,2,,m. 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 U(θ0)U(θ0) which is asymptotically linear as a function of θ0θ0.
The confidence interval limits are also based on the inversion of the Mann–Whitney test statistic.
Given a desired percentage for the confidence interval, 1α1-α, expressed as a proportion between 0.00.0 and 1.01.0 initial estimates of the upper and lower confidence limits for the Mann–Whitney UU statistic are found;
Ul = μ0.5 + (σ × Φ1(α / 2))
Uu = μ + 0.5 + (σ × Φ1((1α) / 2))
Ul=μ-0.5+(σ×Φ-1(α/2)) Uu=μ+0.5+(σ×Φ-1((1-α)/2))
where Φ1Φ-1 is the inverse cumulative Normal distribution function.
UlUl and UuUu are rounded to the nearest integer values. These estimates are refined using an exact method, without taking ties into account, if n + m40n+m40 and max (n,m)30max(n,m)30 and a Normal approximation otherwise, to find UlUl and UuUu satisfying
P(UUl)α / 2
P(UUl + 1) > α / 2
P(UUl)α/2 P(UUl+1)>α/2
and
P(UUu)α / 2
P(UUu1) > α / 2.
P(UUu)α /2 P(UUu- 1)>α /2.
The function U(θ0)U(θ0) is a monotonically increasing step function. It is the number of times a score in the second sample, yjyj, precedes a score in the first sample, xi + θxi+θ, where we only count a half if a score in the second sample actually equals a score in the first.
Let Ul = kUl=k; then θl = dk + 1θl=dk+1. This is the largest value θlθl such that U(θl) = UlU(θl)=Ul.
Let Uu = nmkUu=nm-k; then θu = dnmkθu=dnm-k. This is the smallest value θuθu such that U(θu) = UuU(θu)=Uu.
As in the case of θ̂θ^, these equations may be solved using either the exact or iterative methods to find the values θlθl and θuθu.
Then (θl,θu)(θl,θu) is the confidence interval for θθ. The confidence interval is thus defined by those values of θ0θ0 such that the null hypothesis, θ = θ0θ=θ0, is not rejected by the Mann–Whitney two sample rank test at the (100 × α)%(100×α)% 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:     method – string (length ≥ 1)
Specifies the method to be used.
method = 'E'method='E'
The exact algorithm is used.
method = 'A'method='A'
The iterative algorithm is used.
Constraint: method = 'E'method='E' or 'A''A'.
2:     x(n) – double array
n, the dimension of the array, must satisfy the constraint n1n1.
The observations of the first sample, xixi, for i = 1,2,,ni=1,2,,n.
3:     y(m) – double array
m, the dimension of the array, must satisfy the constraint m1m1.
The observations of the second sample, yjyj, for j = 1,2,,mj=1,2,,m.
4:     clevel – double scalar
The confidence interval required, 1α1-α; e.g., for a 95%95% confidence interval set clevel = 0.95clevel=0.95.
Constraint: 0.0 < clevel < 1.00.0<clevel<1.0.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The dimension of the array x.
nn, the size of the first sample.
Constraint: n1n1.
2:     m – int64int32nag_int scalar
Default: The dimension of the array y.
mm, the size of the second sample.
Constraint: m1m1.

Input Parameters Omitted from the MATLAB Interface

wrk iwrk

Output Parameters

1:     theta – double scalar
The estimate of the difference in the location of the two populations, θ̂θ^.
2:     thetal – double scalar
The estimate of the lower limit of the confidence interval, θlθl.
3:     thetau – double scalar
The estimate of the upper limit of the confidence interval, θuθu.
4:     estcl – double scalar
An estimate of the actual percentage confidence of the interval found, as a proportion between (0.0,1.0)(0.0,1.0).
5:     ulower – double scalar
The value of the Mann–Whitney UU statistic corresponding to the lower confidence limit, UlUl.
6:     uupper – double scalar
The value of the Mann–Whitney UU statistic corresponding to the upper confidence limit, UuUu.
7:     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:

Cases prefixed with W are classified as warnings and do not generate an error of type NAG:error_n. See nag_issue_warnings.

  ifail = 1ifail=1
On entry,method'E'method'E' or 'A''A',
orn < 1n<1,
orm < 1m<1,
orclevel0.0clevel0.0,
orclevel1.0clevel1.0.
W ifail = 2ifail=2
Each sample consists of identical values. All estimates are set to the common difference between the samples.
W ifail = 3ifail=3
For at least one of the estimates θ̂θ^, θlθl and θuθu, the underlying iterative algorithm (when method = 'A'method='A') failed to converge. This is an unlikely exit but the estimate should still be a reasonable approximation.

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 0.00001 × (thetauthetal)0.00001×(thetau-thetal).

Further Comments

The time taken increases with the sample sizes nn and mm.

Example

function nag_univar_robust_2var_ci_example
method = 'Approx';
x = [-0.582;
     0.157;
     -0.523;
     -0.769;
     2.338;
     1.664;
     -0.981;
     1.549;
     1.131;
     -0.46;
     -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.96;
     0.025;
     0.638;
     0.937;
     -0.568;
     -0.711;
     0.931;
     2.601;
     1.121;
     -0.251;
     -0.05;
     1.341;
     2.282;
     0.745;
     1.633;
     0.944;
     2.37;
     0.293;
     0.895;
     0.938;
     0.199;
     0.812;
     1.253;
     0.59;
     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.49;
     0.077;
     1.366;
     0.056;
     0.605;
     0.628;
     1.65;
     0.104;
     2.194;
     2.869;
     -0.171;
     -0.598;
     2.134;
     0.917;
     0.63;
     0.209;
     1.328;
     0.368;
     0.756;
     2.645;
     1.161;
     0.347;
     0.92;
     1.256;
     -0.052;
     1.474;
     0.51;
     1.386;
     3.55;
     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.23;
     0.212;
     0.536;
     1.69;
     1.086;
     0.494];
clevel = 0.95;
[theta, thetal, thetau, estcl, ulower, uupper, ifail] = ...
    nag_univar_robust_2var_ci(method, x, y, clevel)
 

theta =

    0.9505


thetal =

    0.5650


thetau =

    1.3050


estcl =

    0.9511


ulower =

        2007


uupper =

        2993


ifail =

                    0


function g07eb_example
method = 'Approx';
x = [-0.582;
     0.157;
     -0.523;
     -0.769;
     2.338;
     1.664;
     -0.981;
     1.549;
     1.131;
     -0.46;
     -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.96;
     0.025;
     0.638;
     0.937;
     -0.568;
     -0.711;
     0.931;
     2.601;
     1.121;
     -0.251;
     -0.05;
     1.341;
     2.282;
     0.745;
     1.633;
     0.944;
     2.37;
     0.293;
     0.895;
     0.938;
     0.199;
     0.812;
     1.253;
     0.59;
     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.49;
     0.077;
     1.366;
     0.056;
     0.605;
     0.628;
     1.65;
     0.104;
     2.194;
     2.869;
     -0.171;
     -0.598;
     2.134;
     0.917;
     0.63;
     0.209;
     1.328;
     0.368;
     0.756;
     2.645;
     1.161;
     0.347;
     0.92;
     1.256;
     -0.052;
     1.474;
     0.51;
     1.386;
     3.55;
     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.23;
     0.212;
     0.536;
     1.69;
     1.086;
     0.494];
clevel = 0.95;
[theta, thetal, thetau, estcl, ulower, uupper, ifail] = g07eb(method, x, y, clevel)
 

theta =

    0.9505


thetal =

    0.5650


thetau =

    1.3050


estcl =

    0.9511


ulower =

        2007


uupper =

        2993


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