nag_robust_corr_estim (g02hkc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_robust_corr_estim (g02hkc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_robust_corr_estim (g02hkc) computes a robust estimate of the covariance matrix for an expected fraction of gross errors.

2  Specification

#include <nag.h>
#include <nagg02.h>
void  nag_robust_corr_estim (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)

3  Description

For a set 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 = τ 2 AT A -1  
where τ 2  is a correction factor and A  is a lower triangular matrix found as the solution to the following equations.
z i = A x i - θ  
1 n i=1 n w z i 2 z i = 0  
and
1 n i=1 n u z i 2 z i ziT - I = 0 ,  
where x i  is a vector of length m  containing the elements of the i th row of X,
z i  is a vector of length m ,
I  is the identity matrix and 0 is the zero matrix,
and w  and u  are suitable functions.
nag_robust_corr_estim (g02hkc) uses weight functions:
u t = a u t 2 , if ​ t < a u 2 u t = 1 , if ​ a u 2 t b u 2 u t = b u t 2 , if ​ t > b u 2  
and
w t = 1 , if ​ t c w w t = c w t , if ​ t > c w  
for constants a u , b u  and c w .
These functions solve a minimax problem considered by Huber (1981).
The values of a u , b u  and c w  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)).
Initial estimates of θ j , for j=1,2,,m, are given by the median of the j th column of X  and the initial value of A  is based on the median absolute deviation (see Marazzi (1987)). nag_robust_corr_estim (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:     n IntegerInput
On entry: the number of observations, n .
Constraint: n>1 .
2:     m IntegerInput
On entry: the number of columns of the matrix X , i.e., number of independent variables, m .
Constraint: 1 m n .
3:     x[n×tdx] const doubleInput
On entry: x[i-1×tdx+j-1]  must contain the i th observation for the j th variable, for i=1,2,,n and j=1,2,,m.
4:     tdx IntegerInput
On entry: the stride separating matrix column elements in the array x.
Constraint: tdxm .
5:     eps doubleInput
On entry: the expected fraction of gross errors expected in the sample, ε .
Constraint: 0.0 eps < 1.0 .
6:     cov[m×m+1/2] doubleOutput
On exit: the m × m+1 /2 elements of cov contain the upper triangular part of the covariance matrix. They are stored packed by column, i.e., C ij , ji , is stored in cov[ j j+1 / 2 + i ] , for i=0,1,,m - 1 and j=i,,m - 1.
7:     theta[m] doubleOutput
On exit: the robust estimate of the location arguments θ j , for j=1,2,,m.
8:     max_iter IntegerInput
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Suggested value: max_iter=150 .
Constraint: max_iter>0 .
On entry: indicates if the printing of information on the iterations is required and the rate at which printing is produced.
print_iter0
No iteration monitoring is printed.
print_iter>0
The value of A , θ  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: tol>0.0 .
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).

6  Error Indicators and Warnings

NE_2_INT_ARG_GT
On entry, m=value  while n=value . These arguments must satisfy mn .
NE_2_INT_ARG_LT
On entry, tdx=value  while m=value . These arguments must satisfy tdxm .
NE_ALLOC_FAIL
Dynamic memory allocation failed.
NE_C_ITER_UNSTABLE
The iterative procedure to find C  has become unstable. This may happen if the value of eps is too large.
NE_CONST_COL
On entry, column value of array x has constant value.
NE_INT_ARG_LE
On entry, max_iter must not be less than or equal to 0: max_iter=value .
NE_INT_ARG_LT
On entry, m=value.
Constraint: m1.
On entry, n=value.
Constraint: n2.
NE_NOT_APPEND_FILE
Cannot open file string  for appending.
NE_NOT_CLOSE_FILE
Cannot close file string .
NE_REAL_ARG_GE
On entry, eps must be not be greater than or equal to 1.0: eps=value .
NE_REAL_ARG_LE
On entry, tol must not be less than or equal to 0.0: tol=value .
NE_REAL_ARG_LT
On entry, eps must not be less than 0.0: eps=value .
NE_TOO_MANY
Too many iterations(value ).
The iterative procedure to find the co-variance matrix C , 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) d1 =  the maximum value of the absolute relative change in A
(ii) d2 =  the maximum absolute change in u z i 2
(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

Not applicable.

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 (g02hkce.c)

10.2  Program Data

Program Data (g02hkce.d)

10.3  Program Results

Program Results (g02hkce.r)


nag_robust_corr_estim (g02hkc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

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