NAG Library Routine Document
G02HDF
1 Purpose
G02HDF performs bounded influence regression (-estimates) using an iterative weighted least squares algorithm.
2 Specification
SUBROUTINE G02HDF ( |
CHI, PSI, PSIP0, BETA, INDW, ISIGMA, N, M, X, LDX, Y, WGT, THETA, K, SIGMA, RS, TOL, EPS, MAXIT, NITMON, NIT, WK, IFAIL) |
INTEGER |
INDW, ISIGMA, N, M, LDX, K, MAXIT, NITMON, NIT, IFAIL |
REAL (KIND=nag_wp) |
CHI, PSI, PSIP0, BETA, X(LDX,M), Y(N), WGT(N), THETA(M), SIGMA, RS(N), TOL, EPS, WK((M+4)*N) |
EXTERNAL |
CHI, PSI |
|
3 Description
For the linear regression model
where |
is a vector of length of the dependent variable, |
|
is a by matrix of independent variables of column rank , |
|
is a vector of length of unknown parameters, |
and |
is a vector of length of unknown errors with var , |
G02HDF calculates the M-estimates given by the solution,
, to the equation
where |
is the th residual, i.e., the th element of the vector , |
|
is a suitable weight function, |
|
are suitable weights such as those that can be calculated by using output from G02HBF, |
and |
may be estimated at each iteration by the median absolute deviation of the residuals |
or as the solution to
for a suitable weight function
, where
and
are constants, chosen so that the estimator of
is asymptotically unbiased if the errors,
, have a Normal distribution. Alternatively
may be held at a constant value.
The above describes the Schweppe type regression. If the
are assumed to equal
for all
, then Huber type regression is obtained. A third type, due to Mallows, replaces
(1) by
This may be obtained by use of the transformations
(see
Marazzi (1987)).
The calculation of the estimates of
can be formulated as an iterative weighted least squares problem with a diagonal weight matrix
given by
The value of
at each iteration is given by the weighted least squares regression of
on
. This is carried out by first transforming the
and
by
and then using
F04JGF
.
If
is of full column rank then an orthogonal-triangular (
) decomposition is used; if not, a singular value decomposition is used.
Observations with zero or negative weights are not included in the solution.
Note: there is no explicit provision in the routine for a constant term in the regression model. However, the addition of a dummy variable whose value is for all observations will produce a value of corresponding to the usual constant term.
G02HDF is based on routines in ROBETH, 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 and bounded influence regression in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 2 Institut Universitaire de Médecine Sociale et Préventive, Lausanne
5 Parameters
- 1: CHI – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
If
,
CHI must return the value of the weight function
for a given value of its argument. The value of
must be non-negative.
The specification of
CHI is:
- 1: T – REAL (KIND=nag_wp)Input
On entry: the argument for which
CHI must be evaluated.
CHI must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which G02HDF is called. Parameters denoted as
Input must
not be changed by this procedure.
If
, the actual parameter
CHI may be the dummy routine G02HDZ. (G02HDZ is included in the NAG Library.)
- 2: PSI – REAL (KIND=nag_wp) FUNCTION, supplied by the user.External Procedure
PSI must return the value of the weight function
for a given value of its argument.
The specification of
PSI is:
- 1: T – REAL (KIND=nag_wp)Input
On entry: the argument for which
PSI must be evaluated.
PSI must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which G02HDF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 3: PSIP0 – REAL (KIND=nag_wp)Input
On entry: the value of .
- 4: BETA – REAL (KIND=nag_wp)Input
On entry: if
,
BETA must specify the value of
.
For Huber and Schweppe type regressions,
is the
th percentile of the standard Normal distribution (see
G01FAF). For Mallows type regression
is the solution to
where
is the standard Normal cumulative distribution function (see
S15ABF).
If
,
BETA must specify the value of
.
where
is the standard normal density, i.e.,
.
If
,
BETA is not referenced.
Constraint:
if , .
- 5: INDW – INTEGERInput
On entry: determines the type of regression to be performed.
- Huber type regression.
- Mallows type regression.
- Schweppe type regression.
- 6: ISIGMA – INTEGERInput
On entry: determines how
is to be estimated.
- is held constant at its initial value.
- is estimated by median absolute deviation of residuals.
- is estimated using the function.
- 7: N – INTEGERInput
On entry: , the number of observations.
Constraint:
.
- 8: M – INTEGERInput
On entry: , the number of independent variables.
Constraint:
.
- 9: X(LDX,M) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the values of the
matrix, i.e., the independent variables.
must contain the
th element of
, for
and
.
If
, during calculations the elements of
X will be transformed as described in
Section 3. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input
X and the output
X.
On exit: unchanged, except as described above.
- 10: LDX – INTEGERInput
On entry: the first dimension of the array
X as declared in the (sub)program from which G02HDF is called.
Constraint:
.
- 11: Y(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the data values of the dependent variable.
must contain the value of for the th observation, for .
If
, during calculations the elements of
Y will be transformed as described in
Section 3. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input
Y and the output
Y.
On exit: unchanged, except as described above.
- 12: WGT(N) – REAL (KIND=nag_wp) arrayInput/Output
On entry: the weight for the
th observation, for
.
If
, during calculations elements of
WGT will be transformed as described in
Section 3. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input
WGT and the output
WGT.
If , the th observation is not included in the analysis.
If
,
WGT is not referenced.
On exit: unchanged, except as described above.
- 13: THETA(M) – REAL (KIND=nag_wp) arrayInput/Output
On entry: starting values of the parameter vector
. These may be obtained from least squares regression. Alternatively if
and
or if
and
SIGMA approximately equals the standard deviation of the dependent variable,
, then
, for
may provide reasonable starting values.
On exit: the M-estimate of
, for .
- 14: K – INTEGEROutput
On exit: the column rank of the matrix .
- 15: SIGMA – REAL (KIND=nag_wp)Input/Output
On entry: a starting value for the estimation of
.
SIGMA should be approximately the standard deviation of the residuals from the model evaluated at the value of
given by
THETA on entry.
Constraint:
.
On exit: the final estimate of if or the value assigned on entry if .
- 16: RS(N) – REAL (KIND=nag_wp) arrayOutput
On exit: the residuals from the model evaluated at final value of
THETA, i.e.,
RS contains the vector
.
- 17: TOL – REAL (KIND=nag_wp)Input
On entry: the relative precision for the final estimates. Convergence is assumed when both the relative change in the value of
SIGMA and the relative change in the value of each element of
THETA are less than
TOL.
It is advisable for
TOL to be greater than
.
Constraint:
.
- 18: EPS – REAL (KIND=nag_wp)Input
On entry: a relative tolerance to be used to determine the rank of
. See
F04JGF for further details.
If
or
then
machine precision will be used in place of
TOL.
A reasonable value for
EPS is
where this value is possible.
- 19: MAXIT – INTEGERInput
On entry: the maximum number of iterations that should be used during the estimation.
A value of should be adequate for most uses.
Constraint:
.
- 20: NITMON – INTEGERInput
On entry: determines the amount of information that is printed on each iteration.
- No information is printed.
- On the first and every NITMON iterations the values of SIGMA, THETA and the change in THETA during the iteration are printed.
When printing occurs the output is directed to the current advisory message unit (see
X04ABF).
- 21: NIT – INTEGEROutput
On exit: the number of iterations that were used during the estimation.
- 22: WK() – REAL (KIND=nag_wp) arrayWorkspace
- 23: 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, because for this routine the values of the output parameters may be useful even if
on exit, 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).
Note: G02HDF may return useful information for one or more of the following detected errors or warnings.
Errors or warnings detected by the routine:
On entry, | , |
or | , |
or | , |
or | . |
On entry, | , and , |
or | . |
-
On entry, | , |
or | . |
A value returned by the
CHI function is negative.
During iterations a value of was encountered.
A failure occurred in
F04JGF . This is an extremely unlikely error. If it occurs, please contact
NAG.
The weighted least squares equations are not of full rank. This may be due to the
matrix not being of full rank, in which case the results will be valid. It may also occur if some of the
values become very small or zero, see
Section 8. The rank of the equations is given by
K. If the matrix just fails the test for nonsingularity then the result
and
is possible (see
F04JGF).
-
The routine has failed to converge in
MAXIT iterations.
Having removed cases with zero weight, the value of , i.e., no degree of freedom for error. This error will only occur if .
7 Accuracy
The accuracy of the results is controlled by
TOL.
For the accuracy of the weighted least squares see
F04JGF.
In cases when
it is important for the value of
SIGMA to be of a reasonable magnitude. Too small a value may cause too many of the winsorized residuals, i.e.,
, to be zero, which will lead to convergence problems and may trigger the
error.
By suitable choice of the functions
CHI and
PSI this routine may be used for other applications of iterative weighted least squares.
For the variance-covariance matrix of
see
G02HFF.
9 Example
Having input , and the weights, a Schweppe type regression is performed using Huber's function. The subroutine BETCAL calculates the appropriate value of .
9.1 Program Text
Program Text (g02hdfe.f90)
9.2 Program Data
Program Data (g02hdfe.d)
9.3 Program Results
Program Results (g02hdfe.r)