NAG Library Function Document
nag_robust_m_regsn_wts (g02hbc)
1 Purpose
nag_robust_m_regsn_wts (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. nag_robust_m_regsn_wts (g02hbc) is intended for the calculation of weights of bounded influence regression using
nag_robust_m_regsn_user_fn (g02hdc).
2 Specification
#include <nag.h> |
#include <nagg02.h> |
void |
nag_robust_m_regsn_wts (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) |
|
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 arguments, |
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
nag_robust_m_regsn_user_fn (g02hdc) may then be computed using
for a suitable user-supplied function
.
nag_robust_m_regsn_wts (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.
nag_robust_m_regsn_wts (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:
order – 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.2.1.3 in the Essential Introduction for a more detailed explanation of the use of this argument.
Constraint:
or .
- 2:
ucv – 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.
The specification of
ucv is:
double |
ucv (double t,
Nag_Comm *comm)
|
|
- 1:
t – doubleInput
On entry: the argument for which
ucv must be evaluated.
- 2:
comm – 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 nag_robust_m_regsn_wts (g02hbc) you may allocate memory and initialize these pointers with various quantities for use by
ucv when called from nag_robust_m_regsn_wts (g02hbc) (see
Section 3.2.1.1 in the Essential Introduction).
- 3:
n – IntegerInput
On entry: , the number of observations.
Constraint:
.
- 4:
m – IntegerInput
On entry: , the number of independent variables.
Constraint:
.
- 5:
x[] – 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:
pdx – IntegerInput
-
On entry: the stride separating row or column elements (depending on the value of
order) in the array
x.
Constraints:
- if ,
;
- if , .
- 7:
a[] – 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:
z[n] – doubleOutput
On exit: the value
, for .
- 9:
bl – doubleInput
On entry: the magnitude of the bound for the off-diagonal elements of .
Suggested value:
.
Constraint:
.
- 10:
bd – doubleInput
On entry: the magnitude of the bound for the diagonal elements of .
Suggested value:
.
Constraint:
.
- 11:
tol – 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:
maxit – 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:
nitmon – 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:
outfile – 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:
nit – Integer *Output
On exit: the number of iterations performed.
- 16:
comm – Nag_Comm *Communication Structure
-
The NAG communication argument (see
Section 3.2.1.1 in the Essential Introduction).
- 17:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- 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
:
.
- 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.
- 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, diagonal element
of
a is
.
7 Accuracy
On successful exit the accuracy of the results is related to the value of
tol; see
Section 5.
8 Parallelism and Performance
nag_robust_m_regsn_wts (g02hbc) is not threaded by NAG in any implementation.
nag_robust_m_regsn_wts (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
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
Program Text (g02hbce.c)
10.2 Program Data
Program Data (g02hbce.d)
10.3 Program Results
Program Results (g02hbce.r)