NAG Library Routine Document
G02HKF
1 Purpose
G02HKF computes a robust estimate of the covariance matrix for an expected fraction of gross errors.
2 Specification
SUBROUTINE G02HKF ( |
N, M, X, LDX, EPS, COV, THETA, MAXIT, NITMON, TOL, NIT, WK, IFAIL) |
INTEGER |
N, M, LDX, MAXIT, NITMON, NIT, IFAIL |
REAL (KIND=nag_wp) |
X(LDX,M), EPS, COV(M*(M+1)/2), THETA(M), TOL, WK(N+M*(M+5)/2) |
|
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 X, |
|
is a vector of length , |
|
is the identity matrix and is the zero matrix, |
and |
and are suitable functions. |
G02HKF uses weight functions:
and
for constants
,
and
.
These functions solve a minimax problem considered by Huber (see
Huber (1981)). The values of
,
and
are calculated from the expected fraction of gross errors,
(see
Huber (1981) and
Marazzi (1987)). The expected fraction of gross errors is the estimated proportion of outliers in the sample.
In order to make the estimate asymptotically unbiased under a Normal model a correction factor,
, is calculated, (see
Huber (1981) and
Marazzi (1987)).
The matrix
is calculated using
G02HLF. Initial estimates of
, for
, are given by the median of the
th column of
and the initial value of
is based on the median absolute deviation (see
Marazzi (1987)). G02HKF 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: N – INTEGERInput
On entry: , the number of observations.
Constraint:
.
- 2: M – INTEGERInput
On entry: , the number of columns of the matrix , i.e., number of independent variables.
Constraint:
.
- 3: X(LDX,M) – REAL (KIND=nag_wp) arrayInput
On entry: must contain the th observation for the th variable, for and .
- 4: LDX – INTEGERInput
On entry: the first dimension of the array
X as declared in the (sub)program from which G02HKF is called.
Constraint:
.
- 5: EPS – REAL (KIND=nag_wp)Input
On entry: , the expected fraction of gross errors expected in the sample.
Constraint:
.
- 6: COV() – REAL (KIND=nag_wp) arrayOutput
On exit: a robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns. is returned in , .
- 7: THETA(M) – REAL (KIND=nag_wp) arrayOutput
On exit: the robust estimate of the location parameters
, for .
- 8: MAXIT – INTEGERInput
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Constraint:
.
- 9: 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).
- 10: TOL – REAL (KIND=nag_wp)Input
On entry: the relative precision for the final estimates of the covariance matrix.
Constraint:
.
- 11: NIT – INTEGEROutput
On exit: the number of iterations performed.
- 12: WK() – REAL (KIND=nag_wp) arrayWorkspace
- 13: 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 | , |
or | . |
On entry, | a variable has a constant value, i.e., all elements in a column of are identical. |
The iterative procedure to find
has failed to converge in
MAXIT iterations.
The iterative procedure to find
has become unstable. This may happen if the value of
EPS is too large for the sample.
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 the absolute relative change in |
(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
, and hence
, 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 and the robust estimate of the covariance matrix is computed assuming 10% gross errors are to be expected. The robust covariance is then printed.
9.1 Program Text
Program Text (g02hkfe.f90)
9.2 Program Data
Program Data (g02hkfe.d)
9.3 Program Results
Program Results (g02hkfe.r)