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..::..Int32On entry: , the number of observations.Constraint: .
- m
- Type: System..::..Int32On entry: , the number of columns of the matrix , i.e., number of independent variables.Constraint: .
- x
- Type: array<System..::..Double,2>[,](,)[,][,]An array of size [dim1, m]Note: dim1 must satisfy the constraint:On entry: must contain the th observation for the th variable, for and .
- eps
- Type: System..::..DoubleOn entry: , the expected fraction of gross errors expected in the sample.Constraint: .
- cov
- Type: array<System..::..Double>[]()[][]An array of size []On exit: a robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns. is returned in , .
- theta
- Type: array<System..::..Double>[]()[][]An array of size [m]On exit: the robust estimate of the location parameters , for .
- maxit
- Type: System..::..Int32On entry: the maximum number of iterations that will be used during the calculation of the covariance matrix.Constraint: .
- nitmon
- Type: System..::..Int32On entry: indicates the amount of information on the iteration that is printed.
- The value of , and (see [Accuracy]) 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 not in this release)).
- tol
- Type: System..::..DoubleOn entry: the relative precision for the final estimates of the covariance matrix.Constraint: .
- nit
- Type: System..::..Int32%On exit: the number of iterations performed.
- ifail
- Type: System..::..Int32%On exit: unless the method detects an error or a warning has been flagged (see [Error Indicators and Warnings]).
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. |
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 g02hl. 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)). 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.
On entry, , or , or , or , or , or , or .
On entry, a variable has a constant value, i.e., all elements in a column of 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.
Accuracy
On successful exit the accuracy of the results is related to the value of tol; see [Parameters]. At an iteration let
and let . Then the iterative procedure is assumed to have converged when .
(i) | the maximum value of the absolute relative change in |
(ii) | the maximum absolute change in |
(iii) | the maximum absolute relative change in |
Parallelism and Performance
None.
Further Comments
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.
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.
Example program (C#): g02hke.cs