g02hk computes a robust estimate of the covariance matrix for an expected fraction of gross errors.

Syntax

C#
public static void g02hk(
	int n,
	int m,
	double[,] x,
	double eps,
	double[] cov,
	double[] theta,
	int maxit,
	int nitmon,
	double tol,
	out int nit,
	out int ifail
)
Visual Basic
Public Shared Sub g02hk ( _
	n As Integer, _
	m As Integer, _
	x As Double(,), _
	eps As Double, _
	cov As Double(), _
	theta As Double(), _
	maxit As Integer, _
	nitmon As Integer, _
	tol As Double, _
	<OutAttribute> ByRef nit As Integer, _
	<OutAttribute> ByRef ifail As Integer _
)
Visual C++
public:
static void g02hk(
	int n, 
	int m, 
	array<double,2>^ x, 
	double eps, 
	array<double>^ cov, 
	array<double>^ theta, 
	int maxit, 
	int nitmon, 
	double tol, 
	[OutAttribute] int% nit, 
	[OutAttribute] int% ifail
)
F#
static member g02hk : 
        n : int * 
        m : int * 
        x : float[,] * 
        eps : float * 
        cov : float[] * 
        theta : float[] * 
        maxit : int * 
        nitmon : int * 
        tol : float * 
        nit : int byref * 
        ifail : int byref -> unit 

Parameters

n
Type: System..::..Int32
On entry: n, the number of observations.
Constraint: n>1.
m
Type: System..::..Int32
On entry: m, the number of columns of the matrix X, i.e., number of independent variables.
Constraint: 1mn.
x
Type: array<System..::..Double,2>[,](,)[,][,]
An array of size [dim1, m]
Note: dim1 must satisfy the constraint: dim1n
On entry: x[i-1,j-1] must contain the ith observation for the jth variable, for i=1,2,,n and j=1,2,,m.
eps
Type: System..::..Double
On entry: ε, the expected fraction of gross errors expected in the sample.
Constraint: 0.0eps<1.0.
cov
Type: array<System..::..Double>[]()[][]
An array of size [m×m+1/2]
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 cov[j×j-1/2+i-1], ij.
theta
Type: array<System..::..Double>[]()[][]
An array of size [m]
On exit: the robust estimate of the location parameters θj, for j=1,2,,m.
maxit
Type: System..::..Int32
On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.
Constraint: maxit>0.
nitmon
Type: System..::..Int32
On entry: indicates the amount of information on the iteration that is printed.
nitmon>0
The value of A, θ and δ (see [Accuracy]) 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 not in this release)).
tol
Type: System..::..Double
On entry: the relative precision for the final estimates of the covariance matrix.
Constraint: tol>0.0.
nit
Type: System..::..Int32%
On exit: the number of iterations performed.
ifail
Type: System..::..Int32%
On exit: ifail=0 unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).

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-θ,
1ni=1nwzi2zi=0,
and
1ni=1nuzi2ziziT-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.
g02hk uses weight functions:
ut=aut2,if ​t<au2ut=1,if ​au2tbu2ut=but2,if ​t>bu2
and
wt=1,if ​tcwwt=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 g02hl. 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)). g02hk is based on routines in ROBETH; see Marazzi (1987).

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

Error Indicators and Warnings

Errors or warnings detected by the method:
Some error messages may refer to parameters that are dropped from this interface (LDX) In these cases, an error in another parameter has usually caused an incorrect value to be inferred.
ifail=1
On entry,n1,
orm<1,
orn<m,
oreps<0.0,
oreps1.0,
ortol0.0,
ormaxit0.
ifail=2
On entry,a variable has a constant value, i.e., all elements in a column 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=-9000
An error occured, see message report.
ifail=-6000
Invalid Parameters value
ifail=-4000
Invalid dimension for array value
ifail=-8000
Negative dimension for array value
ifail=-6000
Invalid Parameters value

Accuracy

On successful exit the accuracy of the results is related to the value of tol; see [Parameters]. 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.

Parallelism and Performance

None.

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.

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.

Example program (C#): g02hke.cs

Example program data: g02hke.d

Example program results: g02hke.r

See Also