NAG CL Interface
g02hbc (robustm_wts)
1
Purpose
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.
2
Specification
void |
g02hbc (Nag_OrderType order,
double |
(*ucv)(double t,
Nag_Comm *comm),
|
|
Integer n,
Integer m,
const double x[],
Integer pdx,
double a[],
double z[],
double bl,
double bd,
double tol,
Integer maxit,
Integer nitmon,
const char *outfile,
Integer *nit,
Nag_Comm *comm,
NagError *fail) |
|
The function may be called by the names: g02hbc, nag_correg_robustm_wts or nag_robust_m_regsn_wts.
3
Description
In fitting the linear regression model
where |
is a vector of length of the dependent variable, |
|
is an by 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 by 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).
4
References
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
5
Arguments
-
1:
– Nag_OrderType
Input
-
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 user
External Function
-
ucv must return the value of the function
for a given value of its argument. The value of
must be non-negative.
The specification of
ucv is:
double |
ucv (double t,
Nag_Comm *comm)
|
|
-
1:
– double
Input
-
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:
– Integer
Input
-
On entry: , the number of observations.
Constraint:
.
-
4:
– Integer
Input
-
On entry: , the number of independent variables.
Constraint:
.
-
5:
– const double
Input
-
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:
– Integer
Input
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
x.
Constraints:
- if ,
;
- if , .
-
7:
– double
Input/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:
– double
Output
-
On exit: the value
, for .
-
9:
– double
Input
-
On entry: the magnitude of the bound for the off-diagonal elements of .
Suggested value:
.
Constraint:
.
-
10:
– double
Input
-
On entry: the magnitude of the bound for the diagonal elements of .
Suggested value:
.
Constraint:
.
-
11:
– double
Input
-
On entry: the relative precision for the final value of
. Iteration will stop when the maximum value of
is less than
tol.
Constraint:
.
-
12:
– Integer
Input
-
On entry: the maximum number of iterations that will be used during the calculation of
.
A value of will often be adequate.
Constraint:
.
-
13:
– Integer
Input
-
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).
6
Error 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.
7
Accuracy
On successful exit the accuracy of the results is related to the value of
tol; see
Section 5.
8
Parallelism 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.
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.
10
Example
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.
10.1
Program Text
10.2
Program Data
10.3
Program Results