g02hm computes a robust estimate of the covariance matrix for user-supplied weight functions. The derivatives of the weight functions are not required.
Public Shared Sub g02hm ( _ ucv As G02..::..G02HM_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 _ )
- Type: NagLibrary..::..G02..::..G02HM_UCVucv must return the values of the functions and for a given value of its argument.
A delegate of type G02HM_UCV.
- Type: System..::..Int32On entry: indicates which form of the function will be used.
- Type: System..::..Int32On entry: , the number of observations.Constraint: .
- Type: System..::..Int32On entry: , the number of columns of the matrix , i.e., number of independent variables.Constraint: .
- 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 .
- 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 (lower triangular stored by rows), that is is returned in , .
- 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.
- Type: array<System..::..Double>()An array of size [n]On exit: contains the weights, , for .
- 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 .
- Type: System..::..DoubleOn entry: the magnitude of the bound for the off-diagonal elements of , .Suggested value: .Constraint: .
- Type: System..::..DoubleOn entry: the magnitude of the bound for the diagonal elements of , .Suggested value: .Constraint: .
- Type: System..::..Int32On entry: the maximum number of iterations that will be used during the calculation of .Suggested value: .Constraint: .
- Type: System..::..Int32
- Type: System..::..DoubleOn entry: the relative precision for the final estimate of the covariance matrix. Iteration will stop when maximum (see [Accuracy]) is less than tol.Constraint: .
- Type: System..::..Int32%On exit: the number of iterations performed.
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.
|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.|
g02hm covers two situations:
|(i)||for all ,|
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)).
g02hm finds using the iterative procedure as given by Huber; see Huber (1981).
where , for and is a lower triangular matrix such that
- , for
The value of may be chosen so that is unbiased if the observations are from a given distribution.
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
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.
- Either the sum or the sum is zero. This may be caused by the functions or being too strict for the current estimate of (or ). You should either try a larger initial estimate of or make the and functions less strict.
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.
If derivatives of the and functions are available then the method used in g02hl will usually give much faster convergence.
A sample of observations on three variables is read in along with initial values for and and parameter values for the and functions, and . The covariance matrix computed by g02hm is printed along with the robust estimate of .
ucv computes the Huber's weight functions: