NAG FL Interface
g02hkf (robustm_corr_huber)
1
Purpose
g02hkf computes a robust estimate of the covariance matrix for an expected fraction of gross errors.
2
Specification
Fortran Interface
Subroutine g02hkf ( |
n, m, x, ldx, eps, cov, theta, maxit, nitmon, tol, nit, wk, ifail) |
Integer, Intent (In) |
:: |
n, m, ldx, maxit, nitmon |
Integer, Intent (Inout) |
:: |
ifail |
Integer, Intent (Out) |
:: |
nit |
Real (Kind=nag_wp), Intent (In) |
:: |
x(ldx,m), eps, tol |
Real (Kind=nag_wp), Intent (Out) |
:: |
cov(m*(m+1)/2), theta(m), wk(n+m*(m+5)/2) |
|
C Header Interface
#include <nag.h>
void |
g02hkf_ (const Integer *n, const Integer *m, const double x[], const Integer *ldx, const double *eps, double cov[], double theta[], const Integer *maxit, const Integer *nitmon, const double *tol, Integer *nit, double wk[], Integer *ifail) |
|
C++ Header Interface
#include <nag.h> extern "C" {
void |
g02hkf_ (const Integer &n, const Integer &m, const double x[], const Integer &ldx, const double &eps, double cov[], double theta[], const Integer &maxit, const Integer &nitmon, const double &tol, Integer &nit, double wk[], Integer &ifail) |
}
|
The routine may be called by the names g02hkf or nagf_correg_robustm_corr_huber.
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
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:
– Real (Kind=nag_wp) array
Input
-
On entry: must contain the th observation for the th variable, for and .
-
4:
– Integer
Input
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g02hkf is called.
Constraint:
.
-
5:
– Real (Kind=nag_wp)
Input
-
On entry: , the expected fraction of gross errors expected in the sample.
Constraint:
.
-
6:
– Real (Kind=nag_wp) array
Output
-
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:
– Real (Kind=nag_wp) array
Output
-
On exit: the robust estimate of the location parameters
, 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 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:
– Real (Kind=nag_wp)
Input
-
On entry: the relative precision for the final estimates of the covariance matrix.
Constraint:
.
-
11:
– Integer
Output
-
On exit: the number of iterations performed.
-
12:
– Real (Kind=nag_wp) array
Workspace
-
-
13:
– Integer
Input/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.
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).
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, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, .
Constraint: .
-
On entry, a variable has a constant value, i.e., all elements in column
of
x 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.
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.
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
g02hkf is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
g02hkf 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.
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 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