g02hl calculates a robust estimate of the covariance matrix for user-supplied weight functions and their derivatives.
Syntax
C# |
---|
public static void g02hl( G02..::..G02HL_UCV ucv, int indm, int n, int m, double[,] x, double[] cov, double[] a, double[] wt, double[] theta, double bl, double bd, int maxit, int nitmon, double tol, out int nit, out int ifail ) |
Visual Basic |
---|
Public Shared Sub g02hl ( _ ucv As G02..::..G02HL_UCV, _ indm As Integer, _ n As Integer, _ m As Integer, _ x As Double(,), _ cov As Double(), _ a As Double(), _ wt As Double(), _ theta As Double(), _ bl As Double, _ bd 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 g02hl( G02..::..G02HL_UCV^ ucv, int indm, int n, int m, array<double,2>^ x, array<double>^ cov, array<double>^ a, array<double>^ wt, array<double>^ theta, double bl, double bd, int maxit, int nitmon, double tol, [OutAttribute] int% nit, [OutAttribute] int% ifail ) |
F# |
---|
static member g02hl : ucv : G02..::..G02HL_UCV * indm : int * n : int * m : int * x : float[,] * cov : float[] * a : float[] * wt : float[] * theta : float[] * bl : float * bd : float * maxit : int * nitmon : int * tol : float * nit : int byref * ifail : int byref -> unit |
Parameters
- ucv
- Type: NagLibrary..::..G02..::..G02HL_UCVucv must return the values of the functions and and their derivatives for a given value of its argument.
A delegate of type G02HL_UCV.
- indm
- Type: System..::..Int32On entry: indicates which form of the function will be used.
- .
- .
- 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 on the th variable, for and .
- cov
- Type: array<System..::..Double>[]()[][]An array of size []On exit: contains a robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns (lower triangular stored by rows), is returned in , .
- a
- Type: array<System..::..Double>[]()[][]An array of size []On entry: an initial estimate of the lower triangular real matrix . Only the lower triangular elements must be given and these should be stored row-wise in the array.The diagonal elements must be , and in practice will usually be . If the magnitudes of the columns of are of the same order, the identity matrix will often provide a suitable initial value for . If the columns of are of different magnitudes, the diagonal elements of the initial value of should be approximately inversely proportional to the magnitude of the columns of .Constraint: , for .On exit: the lower triangular elements of the inverse of the matrix , stored row-wise.
- wt
- Type: array<System..::..Double>[]()[][]An array of size [n]On exit: contains the weights, , for .
- theta
- Type: array<System..::..Double>[]()[][]An array of size [m]On entry: an initial estimate of the location parameter, , for .In many cases an initial estimate of , for , will be adequate. Alternatively medians may be used as given by (G07DAF not in this release).On exit: contains the robust estimate of the location parameter, , for .
- bl
- Type: System..::..DoubleOn entry: the magnitude of the bound for the off-diagonal elements of , .Suggested value: .Constraint: .
- bd
- Type: System..::..DoubleOn entry: the magnitude of the bound for the diagonal elements of , .Suggested value: .Constraint: .
- maxit
- Type: System..::..Int32On entry: the maximum number of iterations that will be used during the calculation of .Suggested value: .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. Iteration will stop when maximum (see [Accuracy]) is less than tol.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 , |
is a vector of length , | |
is the identity matrix and is the zero matrix, | |
and | and are suitable functions. |
g02hl covers two situations:
(i) | for all , |
(ii) | . |
The robust covariance matrix may be calculated from a weighted sum of squares and cross-products matrix about using weights . In case (i) a divisor of is used and in case (ii) a divisor of is used. If , then the robust covariance matrix can be calculated by scaling each row of by and calculating an unweighted covariance matrix about .
In order to make the estimate asymptotically unbiased under a Normal model a correction factor, , is needed. The value of the correction factor will depend on the functions employed (see Huber (1981) and Marazzi (1987)).
g02hl finds using the iterative procedure as given by Huber.
and
where , for and , is a lower triangular matrix such that:
where
- , for
- and and are suitable bounds.
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 ,
On entry, , or , or diagonal element of , or , or .
- A column of x has a constant value.
- The method has failed to converge in maxit iterations.
- One of the following is zero: , or .This may be caused by the functions or being too strict for the current estimate of (or ). You should try either a larger initial estimate of or make and less strict.
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 |
(ii) | the maximum absolute change in |
(iii) | the maximum absolute relative change in |
Parallelism and Performance
None.
Further Comments
The existence of 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 along with initial values for and theta and parameter values for the and functions, and . The covariance matrix computed by g02hl is printed along with the robust estimate of . ucv computes the Huber's weight functions:
and
and their derivatives.
Example program (C#): g02hle.cs