NAG CL Interface
g02hkc (robustm_corr_huber)
1
Purpose
g02hkc computes a robust estimate of the covariance matrix for an expected fraction of gross errors.
2
Specification
void |
g02hkc (Integer n,
Integer m,
const double x[],
Integer tdx,
double eps,
double cov[],
double theta[],
Integer max_iter,
Integer print_iter,
const char *outfile,
double tol,
Integer *iter,
NagError *fail) |
|
The function may be called by the names: g02hkc, nag_correg_robustm_corr_huber or nag_robust_corr_estim.
3
Description
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.
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 0 is the zero matrix, |
and |
and are suitable functions. |
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)).
g02hkc 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
Arguments
-
1:
– Integer
Input
-
On entry: the number of observations, .
Constraint:
.
-
2:
– Integer
Input
-
On entry: the number of columns of the matrix , i.e., number of independent variables, .
Constraint:
.
-
3:
– const double
Input
-
On entry: must contain the th observation for the th variable, for and .
-
4:
– Integer
Input
-
On entry: the stride separating matrix column elements in the array
x.
Constraint:
.
-
5:
– double
Input
-
On entry: the expected fraction of gross errors expected in the sample, .
Constraint:
.
-
6:
– double
Output
-
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:
– double
Output
-
On exit: the robust estimate of the location arguments , for .
-
8:
– Integer
Input
-
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Suggested value:
.
Constraint:
.
-
9:
– Integer
Input
-
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:
– 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:
– double
Input
-
On entry: the relative precision for the final estimates of the covariance matrix.
Constraint:
.
-
12:
– Integer *
Output
-
On exit: the number of iterations performed.
-
13:
– NagError *
Input/Output
-
The NAG error argument (see
Section 7 in the Introduction to the NAG Library CL Interface).
6
Error Indicators and Warnings
- NE_2_INT_ARG_GT
-
On entry, while . These arguments must satisfy .
- NE_2_INT_ARG_LT
-
On entry, while . These arguments must satisfy .
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_C_ITER_UNSTABLE
-
The iterative procedure to find
has become unstable. This may happen if the value of
eps is too large.
- NE_CONST_COL
-
On entry, column
of array
x has constant value.
- NE_INT_ARG_LE
-
On entry,
max_iter must not be less than or equal to 0:
.
- NE_INT_ARG_LT
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_NOT_APPEND_FILE
-
Cannot open file for appending.
- NE_NOT_CLOSE_FILE
-
Cannot close file .
- NE_REAL_ARG_GE
-
On entry,
eps must be not be greater than or equal to 1.0:
.
- NE_REAL_ARG_LE
-
On entry,
tol must not be less than or equal to 0.0:
.
- NE_REAL_ARG_LT
-
On entry,
eps must not be less than 0.0:
.
- NE_TOO_MANY
-
Too many iterations(
).
The iterative procedure to find the co-variance matrix
, has failed to converge in
max_iter iterations.
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
.
8
Parallelism and Performance
g02hkc 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 function. Please also consult the
Users' Note for your implementation for any additional implementation-specific information.
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.
10
Example
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.
10.1
Program Text
10.2
Program Data
10.3
Program Results