nag_robust_m_regsn_wts (g02hbc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

NAG Library Function Document

nag_robust_m_regsn_wts (g02hbc)

 Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_robust_m_regsn_wts (g02hbc) finds, for a real matrix X of full column rank, a lower triangular matrix A such that ATA-1 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
y=Xθ+ε,  
where y is a vector of length n of the dependent variable,
X is an n by m matrix of independent variables,
θ is a vector of length m of unknown arguments,
and ε is a vector of length n of unknown errors,
it may be desirable to bound the influence of rows of the X 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 A has to be found such that
1ni=1nuzi2zi ziT =I​  I​ is the identity matrix  
and
zi=Axi,  
where xi is a vector of length m containing the elements of the ith row of X,
A is an m by m lower triangular matrix,
zi is a vector of length m,
and u is a suitable function.
The weights for use with nag_robust_m_regsn_user_fn (g02hdc) may then be computed using
wi=fzi2  
for a suitable user-supplied function f.
nag_robust_m_regsn_wts (g02hbc) finds A using the iterative procedure
Ak=Sk+IAk-1,  
where Sk=sjl, for j=1,2,,m and l=1,2,,m, is a lower triangular matrix such that and BD and BL are suitable bounds.
In addition the values of zi2, for i=1,2,,n, 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 order=Nag_RowMajor. See Section 2.3.1.3 in How to Use the NAG Library and its Documentation for a more detailed explanation of the use of this argument.
Constraint: order=Nag_RowMajor or Nag_ColMajor.
2:     ucv function, supplied by the userExternal Function
ucv must return the value of the function u for a given value of its argument. The value of u 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.
userdouble *
iuserInteger *
pPointer 
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 2.3.1.1 in How to Use the NAG Library and its Documentation).
3:     n IntegerInput
On entry: n, the number of observations.
Constraint: n>1.
4:     m IntegerInput
On entry: m, the number of independent variables.
Constraint: 1mn.
5:     x[dim] const doubleInput
Note: the dimension, dim, of the array x must be at least
  • max1,pdx×m when order=Nag_ColMajor;
  • max1,n×pdx when order=Nag_RowMajor.
Where Xi,j appears in this document, it refers to the array element
  • x[j-1×pdx+i-1] when order=Nag_ColMajor;
  • x[i-1×pdx+j-1] when order=Nag_RowMajor.
On entry: the real matrix X, i.e., the independent variables. Xi,j must contain the ijth element of x, for i=1,2,,n and j=1,2,,m.
6:     pdx IntegerInput
On entry: the stride separating row or column elements (depending on the value of order) in the array x.
Constraints:
  • if order=Nag_ColMajor, pdxn;
  • if order=Nag_RowMajor, pdxm.
7:     a[m×m+1/2] doubleInput/Output
On entry: an initial estimate of the lower triangular real matrix A. Only the lower triangular elements must be given and these should be stored row-wise in the array.
The diagonal elements must be 0, although in practice will usually be >0. If the magnitudes of the columns of X are of the same order the identity matrix will often provide a suitable initial value for A. If the columns of X are of different magnitudes, the diagonal elements of the initial value of A should be approximately inversely proportional to the magnitude of the columns of X.
On exit: the lower triangular elements of the matrix A, stored row-wise.
8:     z[n] doubleOutput
On exit: the value zi2, for i=1,2,,n.
9:     bl doubleInput
On entry: the magnitude of the bound for the off-diagonal elements of Sk.
Suggested value: bl=0.9.
Constraint: bl>0.0.
10:   bd doubleInput
On entry: the magnitude of the bound for the diagonal elements of Sk.
Suggested value: bd=0.9.
Constraint: bd>0.0.
11:   tol doubleInput
On entry: the relative precision for the final value of A. Iteration will stop when the maximum value of sjl is less than tol.
Constraint: tol>0.0.
12:   maxit IntegerInput
On entry: the maximum number of iterations that will be used during the calculation of A.
A value of maxit=50 will often be adequate.
Constraint: maxit>0.
13:   nitmon IntegerInput
On entry: determines the amount of information that is printed on each iteration.
nitmon>0
The value of A and the maximum value of sjl will be printed at the first and every nitmon iterations.
nitmon0
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 outfile=NULL 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 *
The NAG communication argument (see Section 2.3.1.1 in How to Use the NAG Library and its Documentation).
17:   fail NagError *Input/Output
The NAG error argument (see Section 2.7 in How to Use the NAG Library and its Documentation).

6  Error Indicators and Warnings

NE_ALLOC_FAIL
Dynamic memory allocation failed.
See Section 2.3.1.2 in How to Use the NAG Library and its Documentation for further information.
NE_BAD_PARAM
On entry, argument value had an illegal value.
NE_CONVERGENCE
Iterations to calculate weights failed to converge in maxit iterations: maxit=value.
NE_FUN_RET_VAL
Value returned by ucv function <0: uvalue=value.
NE_INT
On entry, maxit=value.
Constraint: maxit>0.
On entry, n=value.
Constraint: n>1.
On entry, pdx=value.
Constraint: pdx>0.
NE_INT_2
On entry, m=value and n=value.
Constraint: 1mn.
On entry, pdx=value and m=value.
Constraint: pdxm.
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.
An unexpected error has been triggered by this function. Please contact NAG.
See Section 2.7.6 in How to Use the NAG Library and its Documentation for further information.
NE_NO_LICENCE
Your licence key may have expired or may not have been installed correctly.
See Section 2.7.5 in How to Use the NAG Library and its Documentation for further information.
NE_NOT_CLOSE_FILE
Cannot close file value.
NE_NOT_WRITE_FILE
Cannot open file value for writing.
NE_REAL
On entry, bd=value.
Constraint: bd>0.0.
On entry, bl=value.
Constraint: bl>0.0.
On entry, tol=value.
Constraint: tol>0.0.
NE_ZERO_DIAGONAL
On entry, diagonal element value of a is 0.

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) 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.

9  Further Comments

The existence of A will depend upon the function u; (see Hampel et al. (1986) and Marazzi (1987)), also if X is not of full rank a value of A will not be found. If the columns of X 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 A 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)


nag_robust_m_regsn_wts (g02hbc) (PDF version)
g02 Chapter Contents
g02 Chapter Introduction
NAG Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2016