hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_correg_robustm_wts (g02hb)

 Contents

    1  Purpose
    2  Syntax
    7  Accuracy
    9  Example

Purpose

nag_correg_robustm_wts (g02hb) 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_correg_robustm_wts (g02hb) is intended for the calculation of weights of bounded influence regression using nag_correg_robustm_user (g02hd).

Syntax

[a, z, nit, ifail] = g02hb(ucv, x, a, 'n', n, 'm', m, 'bl', bl, 'bd', bd, 'tol', tol, 'maxit', maxit, 'nitmon', nitmon)
[a, z, nit, ifail] = nag_correg_robustm_wts(ucv, x, a, 'n', n, 'm', m, 'bl', bl, 'bd', bd, 'tol', tol, 'maxit', maxit, 'nitmon', nitmon)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: nitmon, tol and maxit were made optional
At Mark 22: n was made optional

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_correg_robustm_user (g02hd) may then be computed using
wi=fzi2  
for a suitable user-supplied function f.
nag_correg_robustm_wts (g02hb) 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_correg_robustm_wts (g02hb) is based on routines in ROBETH; see Marazzi (1987).

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

Parameters

Compulsory Input Parameters

1:     ucv – function handle or string containing name of m-file
ucv must return the value of the function u for a given value of its argument. The value of u must be non-negative.
[result] = ucv(t)

Input Parameters

1:     t – double scalar
The argument for which ucv must be evaluated.

Output Parameters

1:     result – double scalar
The value of ut evaluated at t.
2:     xldxm – double array
ldx, the first dimension of the array, must satisfy the constraint ldxn.
The real matrix X, i.e., the independent variables. xij must contain the ijth element of x, for i=1,2,,n and j=1,2,,m.
3:     am×m+1/2 – double array
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.

Optional Input Parameters

1:     n int64int32nag_int scalar
Default: the first dimension of the array x.
n, the number of observations.
Constraint: n>1.
2:     m int64int32nag_int scalar
Default: the second dimension of the array x.
m, the number of independent variables.
Constraint: 1mn.
3:     bl – double scalar
Default: 0.9
The magnitude of the bound for the off-diagonal elements of Sk.
Constraint: bl>0.0.
4:     bd – double scalar
Default: 0.9
The magnitude of the bound for the diagonal elements of Sk.
Constraint: bd>0.0.
5:     tol – double scalar
Default: 5e-5
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.
6:     maxit int64int32nag_int scalar
Default: 50
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.
7:     nitmon int64int32nag_int scalar
Default: 0
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.
When printing occurs the output is directed to the current advisory message unit (see nag_file_set_unit_advisory (x04ab)).

Output Parameters

1:     am×m+1/2 – double array
The lower triangular elements of the matrix A, stored row-wise.
2:     zn – double array
The value zi2, for i=1,2,,n.
3:     nit int64int32nag_int scalar
The number of iterations performed.
4:     ifail int64int32nag_int scalar
ifail=0 unless the function detects an error (see Error Indicators and Warnings).

Error Indicators and Warnings

Errors or warnings detected by the function:
   ifail=1
On entry,n1,
orm<1,
orn<m,
orldx<n.
   ifail=2
On entry,tol0.0,
ormaxit0,
ordiagonal element of a=0.0,
orbl0.0,
orbd0.0.
   ifail=3
Value returned by ucv<0.
   ifail=4
The function has failed to converge in maxit iterations.
   ifail=-99
An unexpected error has been triggered by this routine. Please contact NAG.
   ifail=-399
Your licence key may have expired or may not have been installed correctly.
   ifail=-999
Dynamic memory allocation failed.

Accuracy

On successful exit the accuracy of the results is related to the value of tol; see Arguments.

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.

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.
function g02hb_example


fprintf('g02hb example results\n\n');

x = [1, -1, -1;
     1, -1,  1;
     1,  1, -1;
     1,  1,  1;
     1,  0,  3];

% Initial values for a
a = [1;
     0;     1;
     0;     0;     1];

% Calculate a
[a, z, nit, ifail] = g02hb( ...
                            @ucv, x, a);

fprintf(' iterations to convergence = %4d\n\n', nit);
mtitle = 'Matrix A:';
n = int64(size(x,2));
uplo   = 'Lower';
diag   = 'Non-unit';
[ifail] = x04cc( ...
                 uplo, diag, n, a, mtitle);
fprintf('\n');
disp('Vector z');
disp(z);
disp('Vector of Krasker-Welsch weights');
disp((1./z));



function [result] = ucv(t)
  ucvc = 2.5;
  result = 1;
  if (t ~= 0)
     q = ucvc/t;
     q2 = q^2;
     [pc, ifail] = s15ab(q);
     l = x02ak;
     if (q2 < -log(l))
        pd = exp(-q2/2)/sqrt(pi*2);
     else
        pd = 0;
     end
     result = (2*pc-1)*(1-q2) + q2 - 2*q*pd;
  end
g02hb example results

 iterations to convergence =   16

 Matrix A:
               1            2            3
 1    1.3208E+00
 2    2.0465E-17  -5.7532E-01
 3    1.4518E+00   6.5281E-17   9.3403E-01

Vector z
    2.4760
    1.9953
    2.4760
    1.9953
    2.5890

Vector of Krasker-Welsch weights
    0.4039
    0.5012
    0.4039
    0.5012
    0.3862


PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015