NAG Library Routine Document
G07EAF
1 Purpose
G07EAF computes a rank based (nonparametric) estimate and confidence interval for the location parameter of a single population.
2 Specification
SUBROUTINE G07EAF ( |
METHOD, N, X, CLEVEL, THETA, THETAL, THETAU, ESTCL, WLOWER, WUPPER, WRK, IWRK, IFAIL) |
INTEGER |
N, IWRK(3*N), IFAIL |
REAL (KIND=nag_wp) |
X(N), CLEVEL, THETA, THETAL, THETAU, ESTCL, WLOWER, WUPPER, WRK(4*N) |
CHARACTER(1) |
METHOD |
|
3 Description
Consider a vector of independent observations,
with unknown common symmetric density
. G07EAF 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
Let
and let
, for
denote the
ordered averages
for
. Then
- if is odd, where ;
- if is even, where .
This estimator arises from inverting the one-sample Wilcoxon signed-rank test statistic,
, for testing the hypothesis that
. Effectively
is a monotonically decreasing 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 averages
; this is because for large
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
for
. 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
which is asymptotically linear as a function of
.
The confidence interval limits are also based on the inversion of the Wilcoxon test statistic.
Given a desired percentage for the confidence interval,
, expressed as a proportion between
and
, initial estimates for the lower and upper confidence limits of the Wilcoxon statistic are found from
and
where
is the inverse cumulative Normal distribution function.
and
are rounded to the nearest integer values. These estimates are then refined using an exact method if
, and a Normal approximation otherwise, to find
and
satisfying
and
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 the 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 Wilcoxon signed-rank test at the level.
4 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
5 Parameters
- 1: – CHARACTER(1)Input
-
On entry: specifies the method to be used.
- The exact algorithm is used.
- The iterative algorithm is used.
Constraint:
or .
- 2: – INTEGERInput
-
On entry: , the sample size.
Constraint:
.
- 3: – REAL (KIND=nag_wp) arrayInput
-
On entry: the sample observations,
, for .
- 4: – REAL (KIND=nag_wp)Input
-
On entry: the confidence interval desired.
For example, for a confidence interval set .
Constraint:
.
- 5: – REAL (KIND=nag_wp)Output
-
On exit: the estimate of the location, .
- 6: – REAL (KIND=nag_wp)Output
-
On exit: the estimate of the lower limit of the confidence interval, .
- 7: – REAL (KIND=nag_wp)Output
-
On exit: the estimate of the upper limit of the confidence interval, .
- 8: – REAL (KIND=nag_wp)Output
-
On exit: an estimate of the actual percentage confidence of the interval found, as a proportion between .
- 9: – REAL (KIND=nag_wp)Output
-
On exit: the upper value of the Wilcoxon test statistic, , corresponding to the lower limit of the confidence interval.
- 10: – REAL (KIND=nag_wp)Output
-
On exit: the lower value of the Wilcoxon test statistic, , corresponding to the upper limit of the confidence interval.
- 11: – REAL (KIND=nag_wp) arrayWorkspace
- 12: – INTEGER arrayWorkspace
-
- 13: – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value 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, | or , |
or | , |
or | , |
or | . |
-
There is not enough information to compute a confidence interval since the whole sample consists of identical values.
-
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.
See
Section 3.8 in the Essential Introduction for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.7 in the Essential Introduction for further information.
Dynamic memory allocation failed.
See
Section 3.6 in the Essential Introduction for further information.
7 Accuracy
G07EAF 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 .
8 Parallelism and Performance
G07EAF is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
Please consult the
X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this routine. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
The time taken increases with the sample size .
10 Example
The following program calculates a 95% confidence interval for , a measure of symmetry of the sample of observations.
10.1 Program Text
Program Text (g07eafe.f90)
10.2 Program Data
Program Data (g07eafe.d)
10.3 Program Results
Program Results (g07eafe.r)