NAG Library Routine Document

g02hkf  (robustm_corr_huber)

 Contents

    1  Purpose
    7  Accuracy

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 nagmk26.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)

3
Description

For a set of n observations on m variables in a matrix X, a robust estimate of the covariance matrix, C, and a robust estimate of location, θ, are given by
C=τ2ATA-1,  
where τ2 is a correction factor and A is a lower triangular matrix found as the solution to the following equations:
zi=Axi-θ,  
1n i= 1nwzi2zi=0,  
and
1ni=1nuzi2zi ziT -I=0,  
where xi is a vector of length m containing the elements of the ith row of x,
zi is a vector of length m,
I is the identity matrix and 0 is the zero matrix,
and w and u are suitable functions.
g02hkf uses weight functions:
ut= aut2, if ​t<au2 ut=1, if ​au2tbu2 ut= but2, if ​t>bu2  
and
wt= 1, if ​tcw wt= cwt, if ​t>cw  
for constants au, bu and cw.
These functions solve a minimax problem considered by Huber (see Huber (1981)). The values of au, bu and cw 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, τ2, is calculated, (see Huber (1981) and Marazzi (1987)).
The matrix C is calculated using g02hlf. Initial estimates of θj, for j=1,2,,m, are given by the median of the jth column of X and the initial value of A 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:     n – IntegerInput
On entry: n, the number of observations.
Constraint: n>1.
2:     m – IntegerInput
On entry: m, the number of columns of the matrix X, i.e., number of independent variables.
Constraint: 1mn.
3:     xldxm – Real (Kind=nag_wp) arrayInput
On entry: xij must contain the ith observation for the jth variable, for i=1,2,,n and j=1,2,,m.
4:     ldx – IntegerInput
On entry: the first dimension of the array x as declared in the (sub)program from which g02hkf is called.
Constraint: ldxn.
5:     eps – Real (Kind=nag_wp)Input
On entry: ε, the expected fraction of gross errors expected in the sample.
Constraint: 0.0eps<1.0.
6:     covm×m+1/2 – Real (Kind=nag_wp) arrayOutput
On exit: a robust estimate of the covariance matrix, C. The upper triangular part of the matrix C is stored packed by columns. Cij is returned in covj×j-1/2+i, ij.
7:     thetam – Real (Kind=nag_wp) arrayOutput
On exit: the robust estimate of the location arguments θj, for j=1,2,,m.
8:     maxit – IntegerInput
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Suggested value: 150.
Constraint: maxit>0.
9:     nitmon – IntegerInput
On entry: indicates the amount of information on the iteration that is printed.
nitmon>0
The value of A, θ and δ (see Section 7) will be printed at the first and every nitmon iterations.
nitmon0
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: tol>0.0.
11:   nit – IntegerOutput
On exit: the number of iterations performed.
12:   wkn+m×m+5/2 – Real (Kind=nag_wp) arrayWorkspace
13:   ifail – IntegerInput/Output
On entry: ifail must be set to 0, -1​ or ​1. If you are unfamiliar with this argument you should refer to Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value -1​ or ​1 is recommended. If the output of error messages is undesirable, then the value 1 is recommended. Otherwise, if you are not familiar with this argument, the recommended value is 0. When the value -1​ or ​1 is used it is essential to test the value of ifail on exit.
On exit: ifail=0 unless the routine detects an error or a warning has been flagged (see Section 6).

6
Error Indicators and Warnings

If on entry ifail=0 or -1, explanatory error messages are output on the current error message unit (as defined by x04aaf).
Errors or warnings detected by the routine:
ifail=1
On entry, eps<0.0 or eps1.0: eps=value.
On entry, ldx=value and n=value.
Constraint: ldxn.
On entry, m=value.
Constraint: m1.
On entry, maxit=value.
Constraint: maxit>0.
On entry, n=value.
Constraint: n2.
On entry, n=value and m=value.
Constraint: nm.
On entry, tol=value.
Constraint: tol>0.0.
ifail=2
On entry, a variable has a constant value, i.e., all elements in column value of x are identical.
ifail=3
The iterative procedure to find C has failed to converge in maxit iterations.
ifail=4
The iterative procedure to find C has become unstable. This may happen if the value of eps is too large for the sample.
ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
See Section 3.9 in How to Use the NAG Library and its Documentation for further information.
ifail=-399
Your licence key may have expired or may not have been installed correctly.
See Section 3.8 in How to Use the NAG Library and its Documentation for further information.
ifail=-999
Dynamic memory allocation failed.
See Section 3.7 in How to Use the NAG Library and its Documentation 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) d1= the maximum value of the absolute relative change in A
(ii) d2= the maximum absolute change in uzi2
(iii) d3= the maximum absolute relative change in θj
and let δ=maxd1,d2,d3. Then the iterative procedure is assumed to have converged when δ<tol.

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.

9
Further Comments

The existence of A, and hence C, will depend upon the function u (see Marazzi (1987)); also if X is not of full rank a value of A will not be found. If the columns of X 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

Program Text (g02hkfe.f90)

10.2
Program Data

Program Data (g02hkfe.d)

10.3
Program Results

Program Results (g02hkfe.r)

© The Numerical Algorithms Group Ltd, Oxford, UK. 2017