NAG Library Routine Document
g02hbf
(robustm_wts)
1
Purpose
g02hbf 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.
g02hbf is intended for the calculation of weights of bounded influence regression using
g02hdf.
2
Specification
Fortran Interface
Subroutine g02hbf ( |
ucv,
n,
m,
x,
ldx,
a,
z,
bl,
bd,
tol,
maxit,
nitmon,
nit,
wk,
ifail) |
Integer, Intent (In) | :: |
n,
m,
ldx,
maxit,
nitmon | Integer, Intent (Inout) | :: |
ifail | Integer, Intent (Out) | :: |
nit | Real (Kind=nag_wp), External | :: |
ucv | Real (Kind=nag_wp), Intent (In) | :: |
x(ldx,m),
bl,
bd,
tol | Real (Kind=nag_wp), Intent (Inout) | :: |
a(m*(m+1)/2) | Real (Kind=nag_wp), Intent (Out) | :: |
z(n),
wk(m*(m+1)/2) |
|
C Header Interface
#include nagmk26.h
void |
g02hbf_ (
double (NAG_CALL *ucv)(
const double *t),
const Integer *n,
const Integer *m,
const double x[],
const Integer *ldx,
double a[],
double z[],
const double *bl,
const double *bd,
const double *tol,
const Integer *maxit,
const Integer *nitmon,
Integer *nit,
double wk[],
Integer *ifail) |
|
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
g02hdf may then be computed using
for a suitable user-supplied function
.
g02hbf 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.
g02hbf 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: – real (Kind=nag_wp) Function, supplied by the user.External Procedure
-
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:
Fortran Interface
Real (Kind=nag_wp) | :: | ucv | Real (Kind=nag_wp), Intent (In) | :: |
t |
|
C Header Interface
#include nagmk26.h
double |
ucv (
const double *t) |
|
- 1: – Real (Kind=nag_wp)Input
-
On entry: the argument for which
ucv must be evaluated.
ucv must either be a module subprogram USEd by, or declared as EXTERNAL in, the (sub)program from which
g02hbf is called. Arguments denoted as
Input must
not be changed by this procedure.
Note: ucv should not return floating-point NaN (Not a Number) or infinity values, since these are not handled by
g02hbf. If your code inadvertently
does return any NaNs or infinities,
g02hbf is likely to produce unexpected results.
- 2: – IntegerInput
-
On entry: , the number of observations.
Constraint:
.
- 3: – IntegerInput
-
On entry: , the number of independent variables.
Constraint:
.
- 4: – Real (Kind=nag_wp) arrayInput
-
On entry: the real matrix , i.e., the independent variables.
must contain the th element of , for and .
- 5: – IntegerInput
-
On entry: the first dimension of the array
x as declared in the (sub)program from which
g02hbf is called.
Constraint:
.
- 6: – Real (Kind=nag_wp) arrayInput/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.
- 7: – Real (Kind=nag_wp) arrayOutput
-
On exit: the value
, for .
- 8: – Real (Kind=nag_wp)Input
-
On entry: the magnitude of the bound for the off-diagonal elements of .
Suggested value:
.
Constraint:
.
- 9: – Real (Kind=nag_wp)Input
-
On entry: the magnitude of the bound for the diagonal elements of .
Suggested value:
.
Constraint:
.
- 10: – Real (Kind=nag_wp)Input
-
On entry: the relative precision for the final value of
. Iteration will stop when the maximum value of
is less than
tol.
Constraint:
.
- 11: – IntegerInput
-
On entry: the maximum number of iterations that will be used during the calculation of
.
A value of will often be adequate.
Constraint:
.
- 12: – 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.
When printing occurs the output is directed to the current advisory message unit (see
x04abf).
- 13: – IntegerOutput
-
On exit: the number of iterations performed.
- 14: – Real (Kind=nag_wp) arrayWorkspace
-
- 15: – IntegerInput/Output
-
On entry:
ifail must be set to
,
. If you are unfamiliar with this argument you should refer to
Section 3.4 in How to Use the NAG Library and its Documentation for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this argument, the recommended value is
.
When the value is used it is essential to test the value of ifail on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6
Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
x04aaf).
Errors or warnings detected by the routine:
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, and .
Constraint: .
On entry, and .
Constraint: .
-
On entry, .
Constraint: .
On entry, .
Constraint: .
On entry, diagonal element
of
a is
.
On entry, .
Constraint: .
On entry, .
Constraint: .
-
Value returned by
ucv function
:
.
-
Iterations to calculate weights failed to converge in
maxit iterations:
.
An unexpected error has been triggered by this routine. Please
contact
NAG.
See
Section 3.9 in How to Use the NAG Library and its Documentation for further information.
Your licence key may have expired or may not have been installed correctly.
See
Section 3.8 in How to Use the NAG Library and its Documentation for further information.
Dynamic memory allocation failed.
See
Section 3.7 in How to Use the NAG Library and its Documentation for further information.
7
Accuracy
On successful exit the accuracy of the results is related to the value of
tol; see
Section 5.
8
Parallelism and Performance
g02hbf 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 routine. 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
Program Text (g02hbfe.f90)
10.2
Program Data
Program Data (g02hbfe.d)
10.3
Program Results
Program Results (g02hbfe.r)