nag_robust_corr_estim (g02hkc) computes a robust estimate of the covariance matrix for an expected fraction of gross errors.
For a set
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.
nag_robust_corr_estim (g02hkc) uses weight functions:
and
for constants
,
and
.
These functions solve a minimax problem considered by
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)).
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)). nag_robust_corr_estim (g02hkc) is based on routines in ROBETH, (see
Marazzi (1987)).
- 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[] – const doubleInput
-
On entry: must contain the th observation for the th variable, for and .
- 4:
tdx – IntegerInput
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
- 5:
eps – doubleInput
-
On entry: the expected fraction of gross errors expected in the sample, .
Constraint:
.
- 6:
cov[] – doubleOutput
-
On exit: the
/2 elements of
cov contain the upper triangular part of the covariance matrix. They are stored packed by column, i.e.,
,
, is stored in
, for
and
.
- 7:
theta[m] – doubleOutput
-
On exit: the robust estimate of the location arguments , for .
- 8:
max_iter – IntegerInput
-
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Suggested value:
.
Constraint:
.
- 9:
print_iter – IntegerInput
-
On entry: indicates if the printing of information on the iterations is required and the rate at which printing is produced.
- No iteration monitoring is printed.
- The value of , and (see Section 9) will be printed at the first and every print_iter iterations.
- 10:
outfile – const char *Input
-
On entry: a null terminated character string giving the name of the file to which results should be printed. If
outfile is
NULL or an empty string then the
stdout stream is used. Note that the file will be opened in the append mode.
- 11:
tol – doubleInput
-
On entry: the relative precision for the final estimates of the covariance matrix.
Constraint:
.
- 12:
iter – Integer *Output
-
On exit: the number of iterations performed.
- 13:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
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
.
Not applicable.
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.
A sample of 10 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.