NAG Library Routine Document
G07DBF
1 Purpose
G07DBF computes an -estimate of location with (optional) simultaneous estimation of the scale using Huber's algorithm.
2 Specification
SUBROUTINE G07DBF ( |
ISIGMA, N, X, IPSI, C, H1, H2, H3, DCHI, THETA, SIGMA, MAXIT, TOL, RS, NIT, WRK, IFAIL) |
INTEGER |
ISIGMA, N, IPSI, MAXIT, NIT, IFAIL |
REAL (KIND=nag_wp) |
X(N), C, H1, H2, H3, DCHI, THETA, SIGMA, TOL, RS(N), WRK(N) |
|
3 Description
The data consists of a sample of size , denoted by , drawn from a random variable .
The
are assumed to be independent with an unknown distribution function of the form
where
is a location parameter, and
is a scale parameter.
-estimators of
and
are given by the solution to the following system of equations:
where
and
are given functions, and
is a constant, such that
is an unbiased estimator when
, for
has a Normal distribution. Optionally, the second equation can be omitted and the first equation is solved for
using an assigned value of
.
The values of are known as the Winsorized residuals.
The following functions are available for
and
in G07DBF.
(a) |
Null Weights
Use of these null functions leads to the mean and standard deviation of the data. |
(b) |
Huber's Function
|
|
|
|
|
|
|
|
(c) |
Hampel's Piecewise Linear Function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(d) |
Andrew's Sine Wave Function
|
|
|
|
|
otherwise |
|
|
(e) |
Tukey's Bi-weight
|
|
|
|
|
otherwise |
|
where , , , and are constants. |
Equations
(1) and
(2) are solved by a simple iterative procedure suggested by Huber:
and
or
The initial values for
and
may either be user-supplied or calculated within G07DBF as the sample median and an estimate of
based on the median absolute deviation respectively.
G07DBF is based upon subroutine LYHALG within the ROBETH library, see
Marazzi (1987).
4 References
Hampel F R, Ronchetti E M, Rousseeuw P J and Stahel W A (1986) Robust Statistics. The Approach Based on Influence Functions Wiley
Huber P J (1981) Robust Statistics Wiley
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
5 Parameters
- 1: ISIGMA – INTEGERInput
On entry: the value assigned to
ISIGMA determines whether
is to be simultaneously estimated.
- The estimation of is bypassed and SIGMA is set equal to .
- is estimated simultaneously.
- 2: N – INTEGERInput
On entry: , the number of observations.
Constraint:
.
- 3: X(N) – REAL (KIND=nag_wp) arrayInput
On entry: the vector of observations, .
- 4: IPSI – INTEGERInput
On entry: which
function is to be used.
- .
- Huber's function.
- Hampel's piecewise linear function.
- Andrew's sine wave,
- Tukey's bi-weight.
- 5: C – REAL (KIND=nag_wp)Input
On entry: if
,
C must specify the parameter,
, of Huber's
function.
C is not referenced if
.
Constraint:
if , .
- 6: H1 – REAL (KIND=nag_wp)Input
- 7: H2 – REAL (KIND=nag_wp)Input
- 8: H3 – REAL (KIND=nag_wp)Input
On entry: if
,
H1,
H2 and
H3 must specify the parameters,
,
, and
, of Hampel's piecewise linear
function.
H1,
H2 and
H3 are not referenced if
.
Constraint:
and if .
- 9: DCHI – REAL (KIND=nag_wp)Input
On entry:
, the parameter of the
function.
DCHI is not referenced if
.
Constraint:
if , .
- 10: THETA – REAL (KIND=nag_wp)Input/Output
On entry: if
then
THETA must be set to the required starting value of the estimation of the location parameter
. A reasonable initial value for
will often be the sample mean or median.
On exit: the -estimate of the location parameter, .
- 11: SIGMA – REAL (KIND=nag_wp)Input/Output
On entry: the role of
SIGMA depends on the value assigned to
ISIGMA, as follows:
- if , SIGMA must be assigned a value which determines the values of the starting points for the calculations of and . If then G07DBF will determine the starting points of and . Otherwise the value assigned to SIGMA will be taken as the starting point for , and THETA must be assigned a value before entry, see above;
- if , SIGMA must be assigned a value which determines the value of , which is held fixed during the iterations, and the starting value for the calculation of . If , then G07DBF will determine the value of as the median absolute deviation adjusted to reduce bias (see G07DAF) and the starting point for . Otherwise, the value assigned to SIGMA will be taken as the value of and THETA must be assigned a relevant value before entry, see above.
On exit: contains the
-estimate of the scale parameter,
, if
ISIGMA was assigned the value
on entry, otherwise
SIGMA will contain the initial fixed value
.
- 12: MAXIT – INTEGERInput
On entry: the maximum number of iterations that should be used during the estimation.
Suggested value:
.
Constraint:
.
- 13: TOL – REAL (KIND=nag_wp)Input
On entry: the relative precision for the final estimates. Convergence is assumed when the increments for
THETA, and
SIGMA are less than
.
Constraint:
.
- 14: RS(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the Winsorized residuals.
- 15: NIT – INTEGEROutput
On exit: the number of iterations that were used during the estimation.
- 16: WRK(N) – REAL (KIND=nag_wp) arrayOutput
On exit: if
on entry,
WRK will contain the
observations in ascending order.
- 17: IFAIL – 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 , |
or | , |
or | . |
On entry, | and , |
or | and , |
or | and , |
or | and , |
or | and , |
or | and , |
or | and . |
-
On entry, | all elements of the input array X are equal. |
-
SIGMA, the current estimate of
, is zero or negative. This error exit is very unlikely, although it may be caused by too large an initial value of
SIGMA.
-
The number of iterations required exceeds
MAXIT.
On completion of the iterations, the Winsorized residuals were all zero. This may occur when using the option with a redescending function, i.e., Hampel's piecewise linear function, Andrew's sine wave, and Tukey's biweight.
If the given value of
is too small, then the standardized residuals
, will be large and all the residuals may fall into the region for which
. This may incorrectly terminate the iterations thus making
THETA and
SIGMA invalid.
Re-enter the routine with a larger value of or with .
7 Accuracy
On successful exit the accuracy of the results is related to the value of
TOL, see
Section 5.
When you supply the initial values, care has to be taken over the choice of the initial value of
. If too small a value of
is chosen then initial values of the standardized residuals
will be large. If the redescending
functions are used, i.e., Hampel's piecewise linear function, Andrew's sine wave, or Tukey's bi-weight, then these large values of the standardized residuals are Winsorized as zero. If a sufficient number of the residuals fall into this category then a false solution may be returned, see page 152 of
Hampel et al. (1986).
9 Example
The following program reads in a set of data consisting of eleven observations of a variable .
For this example, Hampel's Piecewise Linear Function is used (), values for , and along with for the function, being read from the data file.
Using the following starting values various estimates of
and
are calculated and printed along with the number of iterations used:
(a) |
G07DBF determines the starting values, is estimated simultaneously. |
(b) |
You must supply the starting values, is estimated simultaneously. |
(c) |
G07DBF determines the starting values, is fixed. |
(d) |
You must supply the starting values, is fixed. |
9.1 Program Text
Program Text (g07dbfe.f90)
9.2 Program Data
Program Data (g07dbfe.d)
9.3 Program Results
Program Results (g07dbfe.r)