g02hbc finds, for a real matrix of full column rank, a lower triangular matrix such that is proportional to a robust estimate of the covariance of the variables. g02hbc is intended for the calculation of weights of bounded influence regression using g02hdc.
The function may be called by the names: g02hbc, nag_correg_robustm_wts or nag_robust_m_regsn_wts.
3Description
In fitting the linear regression model
where
is a vector of length of the dependent variable,
is an matrix of independent variables,
is a vector of length of unknown parameters,
and
is a vector of length of unknown errors,
it may be desirable to bound the influence of rows of the matrix. This can be achieved by calculating a weight for each observation. Several schemes for calculating weights have been proposed (see Hampel et al. (1986) and Marazzi (1987)). As the different independent variables may be measured on different scales one group of proposed weights aims to bound a standardized measure of influence. To obtain such weights the matrix has to be found such that
and
where
is a vector of length containing the elements of the th row of ,
is an lower triangular matrix,
is a vector of length ,
and
is a suitable function.
The weights for use with g02hdc may then be computed using
for a suitable user-supplied function .
g02hbc finds using the iterative procedure
where , for and , is a lower triangular matrix such that
and and are suitable bounds.
In addition the values of , for , are calculated.
g02hbc is based on routines in ROBETH; see Marazzi (1987).
4References
Hampel F R, Ronchetti E M, Rousseeuw P J and Stahel W A (1986) Robust Statistics. The Approach Based on Influence Functions Wiley
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 value of the function for a given value of its argument. The value of must be non-negative.
On entry: the argument for which ucv must be evaluated.
2: – 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 g02hbc you may allocate memory and initialize these pointers with various quantities for use by ucv when called from g02hbc (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 g02hbc. If your code inadvertently does return any NaNs or infinities, g02hbc is likely to produce unexpected results.
3: – IntegerInput
On entry: , the number of observations.
Constraint:
.
4: – IntegerInput
On entry: , the number of independent variables.
Constraint:
.
5: – 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: the real matrix , i.e., the independent variables.
must contain the th element of , for and .
6: – IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
if ,
;
if , .
7: – 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 , although 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 .
On exit: the lower triangular elements of the matrix , stored row-wise.
8: – doubleOutput
On exit: the value
, for .
9: – doubleInput
On entry: the magnitude of the bound for the off-diagonal elements of .
Suggested value:
.
Constraint:
.
10: – doubleInput
On entry: the magnitude of the bound for the diagonal elements of .
Suggested value:
.
Constraint:
.
11: – doubleInput
On entry: the relative precision for the final value of . Iteration will stop when the maximum value of is less than tol.
Constraint:
.
12: – IntegerInput
On entry: the maximum number of iterations that will be used during the calculation of .
A value of will often be adequate.
Constraint:
.
13: – IntegerInput
On entry: determines the amount of information that is printed on each iteration.
The value of and the maximum value of will be printed at the first and every nitmon iterations.
No iteration monitoring is printed.
14: – 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.
15: – Integer *Output
On exit: the number of iterations performed.
16: – Nag_Comm *
The NAG communication argument (see Section 3.1.1 in the Introduction to the NAG Library CL Interface).
17: – 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_CONVERGENCE
Iterations to calculate weights failed to converge in maxit iterations: .
NE_FUN_RET_VAL
Value returned by ucv function : . The value of must be non-negative.
NE_INT
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, . Constraint: .
NE_INT_2
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.
7Accuracy
On successful exit the accuracy of the results is related to the value of tol; see Section 5.
8Parallelism and Performance
g02hbc 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 Hampel et al. (1986) and 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
This example reads in a matrix of real numbers and computes the Krasker–Welsch weights (see Marazzi (1987)). The matrix and the weights are then printed.