PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_correg_robustm_corr_huber (g02hk)
Purpose
nag_correg_robustm_corr_huber (g02hk) computes a robust estimate of the covariance matrix for an expected fraction of gross errors.
Syntax
[
covar,
theta,
nit,
ifail] = g02hk(
x,
eps, 'n',
n, 'm',
m, 'maxit',
maxit, 'nitmon',
nitmon, 'tol',
tol)
[
covar,
theta,
nit,
ifail] = nag_correg_robustm_corr_huber(
x,
eps, 'n',
n, 'm',
m, 'maxit',
maxit, 'nitmon',
nitmon, 'tol',
tol)
Note: the interface to this routine has changed since earlier releases of the toolbox:
At Mark 23: |
nitmon and tol were made optional |
At Mark 22: |
n was made optional |
Description
For a set of
observations on
variables in a matrix
, a robust estimate of the covariance matrix,
, and a robust estimate of location,
, are given by
where
is a correction factor and
is a lower triangular matrix found as the solution to the following equations:
and
where |
is a vector of length containing the elements of the th row of x, |
|
is a vector of length , |
|
is the identity matrix and is the zero matrix, |
and |
and are suitable functions. |
nag_correg_robustm_corr_huber (g02hk) uses weight functions:
and
for constants
,
and
.
These functions solve a minimax problem considered by Huber (see
Huber (1981)). The values of
,
and
are calculated from the expected fraction of gross errors,
(see
Huber (1981) and
Marazzi (1987)). The expected fraction of gross errors is the estimated proportion of outliers in the sample.
In order to make the estimate asymptotically unbiased under a Normal model a correction factor,
, is calculated, (see
Huber (1981) and
Marazzi (1987)).
The matrix
is calculated using
nag_correg_robustm_corr_user_deriv (g02hl). Initial estimates of
, for
, are given by the median of the
th column of
and the initial value of
is based on the median absolute deviation (see
Marazzi (1987)).
nag_correg_robustm_corr_huber (g02hk) is based on routines in ROBETH; see
Marazzi (1987).
References
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:
– double array
-
ldx, the first dimension of the array, must satisfy the constraint
.
must contain the th observation for the th variable, for and .
- 2:
– double scalar
-
, the expected fraction of gross errors expected in the sample.
Constraint:
.
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 columns of the matrix , i.e., number of independent variables.
Constraint:
.
- 3:
– int64int32nag_int scalar
Default:
.
The maximum number of iterations that will be used during the calculation of the covariance matrix.
Constraint:
.
- 4:
– int64int32nag_int scalar
Default:
Indicates the amount of information on the iteration that is printed.
- The value of , and (see Accuracy) 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)).
- 5:
– double scalar
Default:
The relative precision for the final estimates of the covariance matrix.
Constraint:
.
Output Parameters
- 1:
– double array
-
A robust estimate of the covariance matrix, . The upper triangular part of the matrix is stored packed by columns. is returned in , .
- 2:
– double array
-
The robust estimate of the location arguments
, 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 | , |
or | , |
or | , |
or | , |
or | . |
-
-
On entry, | a variable has a constant value, i.e., all elements in a column of are identical. |
-
-
The iterative procedure to find
has failed to converge in
maxit iterations.
-
-
The iterative procedure to find
has become unstable. This may happen if the value of
eps is too large for the sample.
-
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. At an iteration let
(i) |
the maximum value of the absolute relative change in |
(ii) |
the maximum absolute change in |
(iii) |
the maximum absolute relative change in |
and let
. Then the iterative procedure is assumed to have converged when
Further Comments
The existence of
, and hence
, will depend upon the function
(see
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
A sample of observations on three variables is read in and the robust estimate of the covariance matrix is computed assuming 10% gross errors are to be expected. The robust covariance is then printed.
Open in the MATLAB editor:
g02hk_example
function g02hk_example
fprintf('g02hk example results\n\n');
x = [3.4, 6.9, 12.2;
6.4, 2.5, 15.1;
4.9, 5.5, 14.2;
7.3, 1.9, 18.2;
8.8, 3.6, 11.7;
8.4, 1.3, 17.9;
5.3, 3.1, 15.0;
2.7, 8.1, 7.7;
6.1, 3.0, 21.9;
5.3, 2.2, 13.9];
epsilon = 0.1;
[covar, theta, nit, ifail] = g02hk( ...
x, epsilon);
fprintf(' iterations to convergence = %4d\n\n', nit);
mtitle = 'Covariance matrix';
n = int64(size(x,2));
uplo = 'Upper';
diag = 'Non-unit';
[ifail] = x04cc( ...
uplo, diag, n, covar, mtitle);
fprintf('\n');
disp('Theta');
disp(theta);
g02hk example results
iterations to convergence = 23
Covariance matrix
1 2 3
1 3.4611 -3.6806 4.6818
2 5.3477 -6.6445
3 14.4389
Theta
5.8178
3.6813
15.0369
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015