NAG Library Routine Document
G02HLF
1 Purpose
G02HLF calculates a robust estimate of the covariance matrix for user-supplied weight functions and their derivatives.
2 Specification
SUBROUTINE G02HLF ( |
UCV, RUSER, INDM, N, M, X, LDX, COV, A, WT, THETA, BL, BD, MAXIT, NITMON, TOL, NIT, WK, IFAIL) |
INTEGER |
INDM, N, M, LDX, MAXIT, NITMON, NIT, IFAIL |
REAL (KIND=nag_wp) |
RUSER(*), X(LDX,M), COV(M*(M+1)/2), A(M*(M+1)/2), WT(N), THETA(M), BL, BD, TOL, WK(2*M) |
EXTERNAL |
UCV |
|
3 Description
For a set of
observations on
variables in a matrix
, a robust estimate of the covariance matrix,
, and a robust estimate of location,
, are given by:
where
is a correction factor and
is a lower triangular matrix found as the solution to the following equations.
and
where |
is a vector of length containing the elements of the th row of , |
|
is a vector of length , |
|
is the identity matrix and is the zero matrix, |
and |
and are suitable functions. |
G02HLF covers two situations:
(i) |
for all , |
(ii) |
. |
The robust covariance matrix may be calculated from a weighted sum of squares and cross-products matrix about
using weights
. In case
(i) a divisor of
is used and in case
(ii) a divisor of
is used. If
, then the robust covariance matrix can be calculated by scaling each row of
by
and calculating an unweighted covariance matrix about
.
In order to make the estimate asymptotically unbiased under a Normal model a correction factor,
, is needed. The value of the correction factor will depend on the functions employed (see
Huber (1981) and
Marazzi (1987)).
G02HLF finds
using the iterative procedure as given by Huber.
and
where
, for
and
, is a lower triangular matrix such that:
where
- , for
- and and are suitable bounds.
G02HLF is based on routines in ROBETH; see
Marazzi (1987).
4 References
Huber P J (1981) Robust Statistics Wiley
Marazzi A (1987) Weights for bounded influence regression in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 3 Institut Universitaire de Médecine Sociale et Préventive, Lausanne
5 Parameters
- 1: UCV – SUBROUTINE, supplied by the user.External Procedure
UCV must return the values of the functions
and
and their derivatives for a given value of its argument.
The specification of
UCV is:
REAL (KIND=nag_wp) |
T, RUSER(*), U, UD, W, WD |
|
- 1: T – REAL (KIND=nag_wp)Input
On entry: the argument for which the functions and must be evaluated.
- 2: RUSER() – REAL (KIND=nag_wp) arrayUser Workspace
-
UCV is called with the parameter
RUSER as supplied to G02HLF. You are free to use the array
RUSER to supply information to
UCV as an alternative to using COMMON global variables.
- 3: U – REAL (KIND=nag_wp)Output
On exit: the value of the
function at the point
T.
Constraint:
.
- 4: UD – REAL (KIND=nag_wp)Output
On exit: the value of the derivative of the
function at the point
T.
- 5: W – REAL (KIND=nag_wp)Output
On exit: the value of the
function at the point
T.
Constraint:
.
- 6: WD – REAL (KIND=nag_wp)Output
On exit: the value of the derivative of the
function at the point
T.
UCV must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which G02HLF is called. Parameters denoted as
Input must
not be changed by this procedure.
- 2: RUSER() – REAL (KIND=nag_wp) arrayUser Workspace
-
RUSER is not used by G02HLF, but is passed directly to
UCV and may be used to pass information to this routine as an alternative to using COMMON global variables.
- 3: INDM – INTEGERInput
On entry: indicates which form of the function
will be used.
- .
- .
- 4: N – INTEGERInput
On entry: , the number of observations.
Constraint:
.
- 5: M – INTEGERInput
On entry: , the number of columns of the matrix , i.e., number of independent variables.
Constraint:
.
- 6: X(LDX,M) – REAL (KIND=nag_wp) arrayInput
On entry: must contain the th observation on the th variable, for and .
- 7: LDX – INTEGERInput
On entry: the first dimension of the array
X as declared in the (sub)program from which G02HLF is called.
Constraint:
.
- 8: COV() – REAL (KIND=nag_wp) arrayOutput
On exit: contains a robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns (lower triangular stored by rows), is returned in , .
- 9: A() – REAL (KIND=nag_wp) arrayInput/Output
On entry: an initial estimate of the lower triangular real matrix
. Only the lower triangular elements must be given and these should be stored row-wise in the array.
The diagonal elements must be , and in practice will usually be . If the magnitudes of the columns of are of the same order, the identity matrix will often provide a suitable initial value for . If the columns of are of different magnitudes, the diagonal elements of the initial value of should be approximately inversely proportional to the magnitude of the columns of .
Constraint:
, for .
On exit: the lower triangular elements of the inverse of the matrix , stored row-wise.
- 10: WT(N) – REAL (KIND=nag_wp) arrayOutput
On exit: contains the weights, , for .
- 11: THETA(M) – REAL (KIND=nag_wp) arrayInput/Output
On entry: an initial estimate of the location parameter,
, for
.
In many cases an initial estimate of
, for
, will be adequate. Alternatively medians may be used as given by
G07DAF.
On exit: contains the robust estimate of the location parameter,
, for .
- 12: BL – REAL (KIND=nag_wp)Input
On entry: the magnitude of the bound for the off-diagonal elements of , .
Suggested value:
.
Constraint:
.
- 13: BD – REAL (KIND=nag_wp)Input
On entry: the magnitude of the bound for the diagonal elements of , .
Suggested value:
.
Constraint:
.
- 14: MAXIT – INTEGERInput
On entry: the maximum number of iterations that will be used during the calculation of .
Suggested value:
.
Constraint:
.
- 15: NITMON – INTEGERInput
On entry: indicates the amount of information on the iteration that is printed.
- The value of , and (see Section 7) will be printed at the first and every NITMON iterations.
- No iteration monitoring is printed.
When printing occurs the output is directed to the current advisory message unit (see
X04ABF).
- 16: TOL – REAL (KIND=nag_wp)Input
On entry: the relative precision for the final estimates of the covariance matrix. Iteration will stop when maximum
(see
Section 7) is less than
TOL.
Constraint:
.
- 17: NIT – INTEGEROutput
On exit: the number of iterations performed.
- 18: WK() – REAL (KIND=nag_wp) arrayWorkspace
- 19: 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 | . |
On entry, | , |
or | , |
or | diagonal element of , |
or | , |
or | . |
-
A column of
X has a constant value.
-
Value of
U or
W returned by
.
-
The routine has failed to converge in
MAXIT iterations.
One of the following is zero: , or .
This may be caused by the functions or being too strict for the current estimate of (or ). You should try either a larger initial estimate of or make and less strict.
7 Accuracy
On successful exit the accuracy of the results is related to the value of
TOL; see
Section 5. At an iteration let
(i) |
the maximum value of |
(ii) |
the maximum absolute change in |
(iii) |
the maximum absolute relative change in |
and let
. Then the iterative procedure is assumed to have converged when
.
The existence of
will depend upon the function
(see
Marazzi (1987)); also if
is not of full rank a value of
will not be found. If the columns of
are almost linearly related, then convergence will be slow.
9 Example
A sample of
observations on three variables is read in along with initial values for
and
THETA and parameter values for the
and
functions,
and
. The covariance matrix computed by G02HLF is printed along with the robust estimate of
.
UCV computes the Huber's weight functions:
and
and their derivatives.
9.1 Program Text
Program Text (g02hlfe.f90)
9.2 Program Data
Program Data (g02hlfe.d)
9.3 Program Results
Program Results (g02hlfe.r)