PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_correg_robustm_wts (g02hb)
Purpose
nag_correg_robustm_wts (g02hb) 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_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
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_correg_robustm_user (g02hd) may then be computed using
for a suitable user-supplied function
.
nag_correg_robustm_wts (g02hb) 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_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:
– function handle or string containing name of m-file
-
ucv must return the value of the function
for a given value of its argument. The value of
must be non-negative.
[result] = ucv(t)
Input Parameters
- 1:
– double scalar
-
The argument for which
ucv must be evaluated.
Output Parameters
- 1:
– double scalar
-
The value of
evaluated at
t.
- 2:
– double array
-
ldx, the first dimension of the array, must satisfy the constraint
.
The real matrix , i.e., the independent variables.
must contain the th element of , for and .
- 3:
– double array
-
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 .
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the first dimension of the array
x.
, the number of observations.
Constraint:
.
- 2:
– int64int32nag_int scalar
-
Default:
the second dimension of the array
x.
, the number of independent variables.
Constraint:
.
- 3:
– double scalar
Default:
The magnitude of the bound for the off-diagonal elements of .
Constraint:
.
- 4:
– double scalar
Default:
The magnitude of the bound for the diagonal elements of .
Constraint:
.
- 5:
– double scalar
Default:
The relative precision for the final value of
. Iteration will stop when the maximum value of
is less than
tol.
Constraint:
.
- 6:
– int64int32nag_int scalar
Default:
The maximum number of iterations that will be used during the calculation of
.
A value of will often be adequate.
Constraint:
.
- 7:
– int64int32nag_int scalar
Default:
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
nag_file_set_unit_advisory (x04ab)).
Output Parameters
- 1:
– double array
-
The lower triangular elements of the matrix , stored row-wise.
- 2:
– double array
-
The value
, for .
- 3:
– int64int32nag_int scalar
-
The number of iterations performed.
- 4:
– int64int32nag_int scalar
unless the function detects an error (see
Error Indicators and Warnings).
Error Indicators and Warnings
Errors or warnings detected by the function:
-
-
On entry, | , |
or | , |
or | , |
or | . |
-
-
On entry, | , |
or | , |
or | diagonal element of , |
or | , |
or | . |
-
-
Value returned by .
-
-
The function has failed to converge in
maxit iterations.
-
An unexpected error has been triggered by this routine. Please
contact
NAG.
-
Your licence key may have expired or may not have been installed correctly.
-
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
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.
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.
Open in the MATLAB editor:
g02hb_example
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];
a = [1;
0; 1;
0; 0; 1];
[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)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015