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)

Purpose

nag_correg_robustm_wts (g02hb) finds, for a real matrix XX of full column rank, a lower triangular matrix AA such that (ATA)1(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:
Mark 22: n has been made optional
Mark 23: nitmon, tol, maxit now optional
.

Description

In fitting the linear regression model
y = Xθ + ε,
y=Xθ+ε,
where yy is a vector of length nn of the dependent variable,
XX is an nn by mm matrix of independent variables,
θθ is a vector of length mm of unknown parameters,
and εε is a vector of length nn of unknown errors,
it may be desirable to bound the influence of rows of the XX 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 AA has to be found such that
n
1/nu(zi2)ziziT = I​  (I​ is the identity matrix)
i = 1
1ni=1nu(zi2)zi ziT =I​  (I​ is the identity matrix)
and
zi = Axi,
zi=Axi,
where xixi is a vector of length mm containing the elements of the iith row of XX,
AA is an mm by mm lower triangular matrix,
zizi is a vector of length mm,
and uu is a suitable function.
The weights for use with nag_correg_robustm_user (g02hd) may then be computed using
wi = f(zi2)
wi=f(zi2)
for a suitable user-supplied function ff.
nag_correg_robustm_wts (g02hb) finds AA using the iterative procedure
Ak = (Sk + I)Ak1,
Ak=(Sk+I)Ak-1,
where Sk = (sjl)Sk=(sjl), for j = 1,2,,mj=1,2,,m and l = 1,2,,ml=1,2,,m, is a lower triangular matrix such that and BDBD and BLBL are suitable bounds.
In addition the values of zi2zi2, for i = 1,2,,ni=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 uu for a given value of its argument. The value of uu 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 result of the function.
2:     x(ldx,m) – double array
ldx, the first dimension of the array, must satisfy the constraint ldxnldxn.
The real matrix XX, i.e., the independent variables. x(i,j)xij must contain the ijijth element of xx, for i = 1,2,,ni=1,2,,n and j = 1,2,,mj=1,2,,m.
3:     a(m × (m + 1) / 2m×(m+1)/2) – double array
An initial estimate of the lower triangular real matrix AA. Only the lower triangular elements must be given and these should be stored row-wise in the array.
The diagonal elements must be 00, although in practice will usually be > 0>0. If the magnitudes of the columns of XX are of the same order the identity matrix will often provide a suitable initial value for AA. If the columns of XX are of different magnitudes, the diagonal elements of the initial value of AA should be approximately inversely proportional to the magnitude of the columns of XX.

Optional Input Parameters

1:     n – int64int32nag_int scalar
Default: The first dimension of the array x.
nn, the number of observations.
Constraint: n > 1n>1.
2:     m – int64int32nag_int scalar
Default: The second dimension of the array x.
mm, the number of independent variables.
Constraint: 1mn1mn.
3:     bl – double scalar
The magnitude of the bound for the off-diagonal elements of SkSk.
Default: 0.90.9
Constraint: bl > 0.0bl>0.0.
4:     bd – double scalar
The magnitude of the bound for the diagonal elements of SkSk.
Default: 0.90.9
Constraint: bd > 0.0bd>0.0.
5:     tol – double scalar
The relative precision for the final value of AA. Iteration will stop when the maximum value of |sjl||sjl| is less than tol.
Default: 5e-55e-5
Constraint: tol > 0.0tol>0.0.
6:     maxit – int64int32nag_int scalar
The maximum number of iterations that will be used during the calculation of AA.
A value of maxit = 50maxit=50 will often be adequate.
Default: 5050
Constraint: maxit > 0maxit>0.
7:     nitmon – int64int32nag_int scalar
Determines the amount of information that is printed on each iteration.
nitmon > 0nitmon>0
The value of AA and the maximum value of |sjl||sjl| will be printed at the first and every nitmon iterations.
nitmon0nitmon0
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)).
Default: 00

Input Parameters Omitted from the MATLAB Interface

ldx wk

Output Parameters

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

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,n1n1,
orm < 1m<1,
orn < mn<m,
orldx < nldx<n.
  ifail = 2ifail=2
On entry,tol0.0tol0.0,
ormaxit0maxit0,
ordiagonal element of a = 0.0a=0.0,
orbl0.0bl0.0,
orbd0.0bd0.0.
  ifail = 3ifail=3
Value returned by ucv < 0ucv<0.
  ifail = 4ifail=4
The function has failed to converge in maxit iterations.

Accuracy

On successful exit the accuracy of the results is related to the value of tol; see Section [Parameters].

Further Comments

The existence of AA will depend upon the function uu; (see Hampel et al. (1986) and Marazzi (1987)), also if XX is not of full rank a value of AA will not be found. If the columns of XX are almost linearly related then convergence will be slow.

Example

function nag_correg_robustm_wts_example
x = [1, -1, -1;
     1, -1, 1;
     1, 1, -1;
     1, 1, 1;
     1, 0, 3];
a = [1;
     0;
     1;
     0;
     0;
     1];
[aOut, z, nit, ifail] = nag_correg_robustm_wts(@ucv, x, a)

function [result] = ucv(t)
  ucvc = 2.5;
  result = 1;
  if (t ~= 0.0)
     q = ucvc/t;
     q2 = q*q;
     [pc, ifail] = nag_specfun_cdf_normal(q);
     l = nag_machine_real_smallest;
     if (q2 < -log(l))
        pd = exp(-q2/2.0)/sqrt(pi*2.0);
     else
        pd = 0.0;
     end
     result = (2.0*pc-1.0)*(1.0-q2) + q2 - 2.0*q*pd;
  end
 

aOut =

    1.3208
    0.0000
    1.4518
   -0.5753
    0.0000
    0.9340


z =

    2.4760
    1.9953
    2.4760
    1.9953
    2.5890


nit =

                   16


ifail =

                    0


function g02hb_example
x = [1, -1, -1;
     1, -1, 1;
     1, 1, -1;
     1, 1, 1;
     1, 0, 3];
a = [1;
     0;
     1;
     0;
     0;
     1];
[aOut, z, nit, ifail] = g02hb(@ucv, x, a)

function [result] = ucv(t)
  ucvc = 2.5;
  result = 1;
  if (t ~= 0.0)
     q = ucvc/t;
     q2 = q*q;
     [pc, ifail] = s15ab(q);
     l = x02ak;
     if (q2 < -log(l))
        pd = exp(-q2/2.0)/sqrt(pi*2.0);
     else
        pd = 0.0;
     end
     result = (2.0*pc-1.0)*(1.0-q2) + q2 - 2.0*q*pd;
  end
 

aOut =

    1.3208
    0.0000
    1.4518
   -0.5753
    0.0000
    0.9340


z =

    2.4760
    1.9953
    2.4760
    1.9953
    2.5890


nit =

                   16


ifail =

                    0



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–2013