The function may be called by the names: g02hlc, nag_correg_robustm_corr_user_deriv or nag_robust_m_corr_user_fn.
3Description
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.
g02hlc 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)).
g02hlc 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.
g02hlc is based on routines in ROBETH; see Marazzi (1987).
4References
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
5Arguments
1: – Nag_OrderTypeInput
On entry: the order argument specifies the two-dimensional storage scheme being used, i.e., row-major ordering or column-major ordering. C language defined storage is specified by . See Section 3.1.3 in the Introduction to the NAG Library CL Interface for a more detailed explanation of the use of this argument.
Constraint:
or .
2: – function, supplied by the userExternal Function
ucv must return the values of the functions and and their derivatives for a given value of its argument.
On entry: the argument for which the functions and must be evaluated.
2: – double *Output
On exit: the value of the function at the point t.
Constraint:
.
3: – double *Output
On exit: the value of the derivative of the function at the point t.
4: – double *Output
On exit: the value of the function at the point t.
Constraint:
.
5: – double *Output
On exit: the value of the derivative of the function at the point t.
6: – Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to ucv.
user – double *
iuser – Integer *
p – Pointer
The type Pointer will be void *. Before calling g02hlc you may allocate memory and initialize these pointers with various quantities for use by ucv when called from g02hlc (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
Note:ucv should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by g02hlc. If your code inadvertently does return any NaNs or infinities, g02hlc is likely to produce unexpected results.
3: – IntegerInput
On entry: indicates which form of the function will be used.
.
.
4: – IntegerInput
On entry: , the number of observations.
Constraint:
.
5: – IntegerInput
On entry: , the number of columns of the matrix , i.e., number of independent variables.
Constraint:
.
6: – const doubleInput
Note: the dimension, dim, of the array
x
must be at least
when ;
when .
where appears in this document, it refers to the array element
when ;
when .
On entry: must contain the th observation on the th variable, for and .
7: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
if ,
;
if , .
8: – doubleOutput
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 , .
9: – doubleInput/Output
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.
10: – doubleOutput
On exit: contains the weights, , for .
11: – doubleInput/Output
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 g07dac.
On exit: contains the robust estimate of the location parameter,
, for .
12: – doubleInput
On entry: the magnitude of the bound for the off-diagonal elements of , .
Suggested value:
.
Constraint:
.
13: – doubleInput
On entry: the magnitude of the bound for the diagonal elements of , .
Suggested value:
.
Constraint:
.
14: – IntegerInput
On entry: the maximum number of iterations that will be used during the calculation of .
Suggested value:
.
Constraint:
.
15: – IntegerInput
On entry: indicates the amount of information on the iteration that is printed.
The value of , and (see Section 7) will be printed at the first and every nitmon iterations.
No iteration monitoring is printed.
16: – const char *Input
On entry: a null terminated character string giving the name of the file to which results should be printed. If or an empty string then the stdout stream is used. Note that the file will be opened in the append mode.
17: – doubleInput
On entry: the relative precision for the final estimates of the covariance matrix. Iteration will stop when maximum (see Section 7) is less than tol.
Constraint:
.
18: – Integer *Output
On exit: the number of iterations performed.
19: – Nag_Comm *
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
20: – NagError *Input/Output
The NAG error argument (see Section 7 in the Introduction to the NAG Library CL Interface).
6Error Indicators and Warnings
NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 3.1.2 in the Introduction to the NAG Library CL Interface for further information.
NE_BAD_PARAM
On entry, argument had an illegal value.
NE_CONST_COL
On entry, a variable has a constant value, i.e., all elements in column of x are identical.
NE_CONVERGENCE
Iterations to calculate weights failed to converge.
NE_FUN_RET_VAL
value returned by : .
Constraint: .
value returned by : .
Constraint: .
NE_INT
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, . Constraint: .
NE_INT_2
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
NE_INTERNAL_ERROR
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact NAG for assistance.
See Section 7.5 in the Introduction to the NAG Library CL Interface for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 8 in the Introduction to the NAG Library CL Interface for further information.
NE_NOT_CLOSE_FILE
Cannot close file .
NE_NOT_WRITE_FILE
Cannot open file for writing.
NE_REAL
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, .
Constraint: .
NE_ZERO_DIAGONAL
On entry, and the th diagonal element of is .
Constraint: all diagonal elements of must be non-zero.
NE_ZERO_SUM
The sum is zero. Try either a larger initial estimate of or make and less strict.
The sum is zero. Try either a larger initial estimate of or make and less strict.
The sum is zero. Try either a larger initial estimate of or make and less strict.
7Accuracy
On successful exit the accuracy of the results is related to the value of tol; see Section 5. At an iteration let
(i) the maximum value of
(ii) the maximum absolute change in
(iii) the maximum absolute relative change in
and let . Then the iterative procedure is assumed to have converged when .
8Parallelism and Performance
Background information to multithreading can be found in the Multithreading documentation.
g02hlc makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the X06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the Users' Note for your implementation for any additional implementation-specific information.
9Further 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.
10Example
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 g02hlc is printed along with the robust estimate of . ucv computes the Huber's weight functions: