The routine may be called by the names g02hdf or nagf_correg_robustm_user.
3Description
For the linear regression model
where
is a vector of length of the dependent variable,
is an 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
(1)
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
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).
4References
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
5Arguments
1: – 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.
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. Arguments denoted as Input must not be changed by this procedure.
Note:chi should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by g02hdf. If your code inadvertently does return any NaNs or infinities, g02hdf is likely to produce unexpected results.
If , the actual argument chi may be the dummy routine g02hdz. (g02hdz is included in the NAG Library.)
2: – 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.
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. Arguments denoted as Input must not be changed by this procedure.
Note:psi should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by g02hdf. If your code inadvertently does return any NaNs or infinities, g02hdf is likely to produce unexpected results.
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).
On entry: determines the type of regression to be performed.
Huber type regression.
Mallows type regression.
Schweppe type regression.
6: – 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: – IntegerInput
On entry: , the number of observations.
Constraint:
.
8: – IntegerInput
On entry: , the number of independent variables.
Constraint:
.
9: – 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: – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g02hdf is called.
Constraint:
.
11: – 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: – 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.
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: – IntegerOutput
On exit: the column rank of the matrix .
15: – 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: – 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: – 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.
On entry: a relative tolerance to be used to determine the rank of . See f04jgf for further details.
If or , machine precision will be used in place of tol.
A reasonable value for eps is where this value is possible.
19: – 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: – 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: – IntegerOutput
On exit: the number of iterations that were used during the estimation.
22: – Real (Kind=nag_wp) arrayWorkspace
23: – IntegerInput/Output
On entry: ifail must be set to , or to set behaviour on detection of an error; these values have no effect when no error is detected.
A value of causes the printing of an error message and program execution will be halted; otherwise program execution continues. A value of means that an error message is printed while a value of means that it is not.
If halting is not appropriate, the value or is recommended. If message printing is undesirable, then the value is recommended. Otherwise, the value is recommended since useful values can be provided in some output arguments even when on exit. When the value or 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).
6Error 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:
Note: in some cases g02hdf may return useful information.
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
Value given by chi function : . The value of chi must be non-negative.
Iterations to solve the weighted least squares equations failed to converge.
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 9. 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 .
An unexpected error has been triggered by this routine. Please
contact NAG.
See Section 7 in the Introduction to the NAG Library FL Interface for further information.
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library FL Interface for further information.
Dynamic memory allocation failed.
See Section 9 in the Introduction to the NAG Library FL Interface for further information.
7Accuracy
The accuracy of the results is controlled by tol.
For the accuracy of the weighted least squares see f04jgf.
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g02hdf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02hdf makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
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.
9Further Comments
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.
Having input , and the weights, a Schweppe type regression is performed using Huber's function. The subroutine BETCAL calculates the appropriate value of .