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_1var_ci (g07ea)

Purpose

nag_univar_robust_1var_ci (g07ea) computes a rank based (nonparametric) estimate and confidence interval for the location parameter of a single population.

Syntax

[theta, thetal, thetau, estcl, wlower, wupper, ifail] = g07ea(method, x, clevel, 'n', n)
[theta, thetal, thetau, estcl, wlower, wupper, ifail] = nag_univar_robust_1var_ci(method, x, clevel, 'n', n)

Description

Consider a vector of independent observations, x = (x1,x2,,xn)Tx=(x1,x2,,xn)T with unknown common symmetric density f(xiθ)f(xi-θ). nag_univar_robust_1var_ci (g07ea) computes the Hodges–Lehmann location estimator (see Lehmann (1975)) of the centre of symmetry θθ, together with an associated confidence interval. The Hodges–Lehmann estimate is defined as
θ̂ = median {(xi + xj)/2,1ijn} .
θ^=median {xi+xj2,1ijn} .
Let m = (n(n + 1)) / 2m=(n(n+1))/2 and let akak, for k = 1,2,,mk=1,2,,m denote the mm ordered averages (xi + xj) / 2(xi+xj)/2 for 1ijn1ijn. Then
This estimator arises from inverting the one-sample Wilcoxon signed-rank test statistic, W(xθ0)W(x-θ0), for testing the hypothesis that θ = θ0θ=θ0. Effectively W(xθ0)W(x-θ0) is a monotonically decreasing step function of θ0θ0 with
mean ​(W) = μ = (n(n + 1))/4,
var(W) = σ2 = (n(n + 1)(2n + 1))/24.
mean ​(W)=μ= n(n+1)4, var(W)=σ2= n(n+1)(2n+1)24.
The estimate θ̂θ^ is the solution to the equation W(xθ̂) = μW(x-θ^)=μ; two methods are available for solving this equation. These methods avoid the computation of all the ordered averages akak; this is because for large nn both the storage requirements and the computation time would be excessive.
The first is an exact method based on a set partitioning procedure on the set of all ordered averages (xi + xj) / 2(xi+xj)/2 for ijij. This is based on the algorithm proposed by Monahan (1984).
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 W(xθ0)W(x-θ0) which is asymptotically linear as a function of θ0θ0.
The confidence interval limits are also based on the inversion of the Wilcoxon test statistic.
Given a desired percentage for the confidence interval, 1α1-α, expressed as a proportion between 00 and 11, initial estimates for the lower and upper confidence limits of the Wilcoxon statistic are found from
Wl = μ0.5 + (σΦ1(α / 2))
Wl=μ-0.5+(σΦ-1(α/2))
and
Wu = μ + 0.5 + (σΦ1(1α / 2)),
Wu=μ+ 0.5+(σ Φ-1(1-α /2)),
where Φ1Φ-1 is the inverse cumulative Normal distribution function.
WlWl and WuWu are rounded to the nearest integer values. These estimates are then refined using an exact method if n80n80, and a Normal approximation otherwise, to find WlWl and WuWu satisfying
P(WWl)α / 2
P(WWl + 1) > α / 2
P(WWl)α/2 P(WWl+1)>α/2
and
P(WWu)α / 2
P(WWu1) > α / 2.
P(WWu)α /2 P(WWu- 1)>α /2.
Let Wu = mkWu=m-k; then θl = ak + 1θl=ak+1. This is the largest value θlθl such that W(xθl) = WuW(x-θl)=Wu.
Let Wl = kWl=k; then θu = amkθu=am-k. This is the smallest value θuθu such that W(xθu) = WlW(x-θu)=Wl.
As in the case of θ̂θ^, these equations may be solved using either the exact or the 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 Wilcoxon signed-rank test at the (100 × α)%(100×α)% level.

References

Lehmann E L (1975) Nonparametrics: Statistical Methods Based on Ranks Holden–Day
Marazzi A (1987) Subroutines for robust estimation of location and scale in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 1 Institut Universitaire de Médecine Sociale et Préventive, Lausanne
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 n2n2.
The sample observations, xixi, for i = 1,2,,ni=1,2,,n.
3:     clevel – double scalar
The confidence interval desired.
For example, 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 sample size.
Constraint: n2n2.

Input Parameters Omitted from the MATLAB Interface

wrk iwrk

Output Parameters

1:     theta – double scalar
The estimate of the location, θ̂θ^.
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:     wlower – double scalar
The upper value of the Wilcoxon test statistic, WuWu, corresponding to the lower limit of the confidence interval.
6:     wupper – double scalar
The lower value of the Wilcoxon test statistic, WlWl, corresponding to the upper limit of the confidence interval.
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:
  ifail = 1ifail=1
On entry,method'E'method'E' or 'A''A',
orn < 2n<2,
orclevel0.0clevel0.0,
orclevel1.0clevel1.0.
  ifail = 2ifail=2
There is not enough information to compute a confidence interval since the whole sample consists of identical values.
  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_1var_ci (g07ea) should produce 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 size nn.

Example

function nag_univar_robust_1var_ci_example
method = 'Exact';
x = [-0.23;
     0.35;
     -0.77;
     0.35;
     0.27;
     -0.72;
     0.08;
     -0.4;
     -0.76;
     0.45;
     0.73;
     0.74;
     0.83;
     -0.87;
     0.21;
     0.29;
     -0.91;
     -0.04;
     0.82;
     -0.38;
     -0.31;
     0.24;
     -0.47;
     -0.68;
     -0.77;
     -0.86;
     -0.59;
     0.73;
     0.39;
     -0.44;
     0.63;
     -0.22;
     -0.07;
     -0.43;
     -0.21;
     -0.31;
     0.64;
     -1;
     -0.86;
     -0.73];
clevel = 0.95;
[theta, thetal, thetau, estcl, wlower, wupper, ifail] = ...
    nag_univar_robust_1var_ci(method, x, clevel)
 

theta =

   -0.1300


thetal =

   -0.3300


thetau =

    0.0350


estcl =

    0.9514


wlower =

   556


wupper =

   264


ifail =

                    0


function g07ea_example
method = 'Exact';
x = [-0.23;
     0.35;
     -0.77;
     0.35;
     0.27;
     -0.72;
     0.08;
     -0.4;
     -0.76;
     0.45;
     0.73;
     0.74;
     0.83;
     -0.87;
     0.21;
     0.29;
     -0.91;
     -0.04;
     0.82;
     -0.38;
     -0.31;
     0.24;
     -0.47;
     -0.68;
     -0.77;
     -0.86;
     -0.59;
     0.73;
     0.39;
     -0.44;
     0.63;
     -0.22;
     -0.07;
     -0.43;
     -0.21;
     -0.31;
     0.64;
     -1;
     -0.86;
     -0.73];
clevel = 0.95;
[theta, thetal, thetau, estcl, wlower, wupper, ifail] = g07ea(method, x, clevel)
 

theta =

   -0.1300


thetal =

   -0.3300


thetau =

    0.0350


estcl =

    0.9514


wlower =

   556


wupper =

   264


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