PDF version (NAG web site
, 64-bit version, 64-bit version)
NAG Toolbox: nag_univar_robust_1var_mestim_wgt (g07dc)
Purpose
nag_univar_robust_1var_mestim_wgt (g07dc) computes an -estimate of location with (optional) simultaneous estimation of scale, where you provide the weight functions.
Syntax
[
theta,
sigma,
rs,
nit,
wrk,
ifail] = g07dc(
chi,
psi,
isigma,
x,
beta,
theta,
sigma,
tol, 'n',
n, 'maxit',
maxit)
[
theta,
sigma,
rs,
nit,
wrk,
ifail] = nag_univar_robust_1var_mestim_wgt(
chi,
psi,
isigma,
x,
beta,
theta,
sigma,
tol, 'n',
n, 'maxit',
maxit)
Description
The data consists of a sample of size , denoted by , drawn from a random variable .
The
are assumed to be independent with an unknown distribution function of the form,
where
is a location argument, and
is a scale argument.
-estimators of
and
are given by the solution to the following system of equations;
where
and
are user-supplied weight functions, and
is a constant. Optionally the second equation can be omitted and the first equation is solved for
using an assigned value of
.
The constant
should be chosen so that
is an unbiased estimator when
, for
has a Normal distribution. To achieve this the value of
is calculated as:
The values of
are known as the Winsorized residuals.
The equations are solved by a simple iterative procedure, suggested by Huber:
and
or
if
is fixed.
The initial values for
and
may be user-supplied or calculated within
nag_univar_robust_1var_mestim (g07db) as the sample median and an estimate of
based on the median absolute deviation respectively.
nag_univar_robust_1var_mestim_wgt (g07dc) is based upon function LYHALG within the ROBETH library, 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) Subroutines for robust estimation of location and scale in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 1 Institut Universitaire de Médecine Sociale et Préventive, Lausanne
Parameters
Compulsory Input Parameters
- 1:
– function handle or string containing name of m-file
-
chi must return the value of the weight function
for a given value of its argument. The value of
must be non-negative.
[result] = chi(t)
Input Parameters
- 1:
– double scalar
-
The argument for which
chi must be evaluated.
Output Parameters
- 1:
– double scalar
-
The value of the weight function
evaluated at
t.
- 2:
– function handle or string containing name of m-file
-
psi must return the value of the weight function
for a given value of its argument.
[result] = psi(t)
Input Parameters
- 1:
– double scalar
-
The argument for which
psi must be evaluated.
Output Parameters
- 1:
– double scalar
-
The value of the weight function
evaluated at
t.
- 3:
– int64int32nag_int scalar
-
The value assigned to
isigma determines whether
is to be simultaneously estimated.
- The estimation of is bypassed and sigma is set equal to .
- is estimated simultaneously.
- 4:
– double array
-
The vector of observations, .
- 5:
– double scalar
-
The value of the constant
of the chosen
chi function.
Constraint:
.
- 6:
– double scalar
-
If
, then
theta must be set to the required starting value of the estimate of the location argument
. A reasonable initial value for
will often be the sample mean or median.
- 7:
– double scalar
-
The role of
sigma depends on the value assigned to
isigma as follows.
If
,
sigma must be assigned a value which determines the values of the starting points for the calculation of
and
. If
, then
nag_univar_robust_1var_mestim_wgt (g07dc) will determine the starting points of
and
. Otherwise, the value assigned to
sigma will be taken as the starting point for
, and
theta must be assigned a relevant value before entry, see above.
If
,
sigma must be assigned a value which determines the values of
, which is held fixed during the iterations, and the starting value for the calculation of
. If
, then
nag_univar_robust_1var_mestim_wgt (g07dc) will determine the value of
as the median absolute deviation adjusted to reduce bias (see
nag_univar_robust_1var_median (g07da)) and the starting point for
. Otherwise, the value assigned to
sigma will be taken as the value of
and
theta must be assigned a relevant value before entry, see above.
- 8:
– double scalar
-
The relative precision for the final estimates. Convergence is assumed when the increments for
theta, and
sigma are less than
.
Constraint:
.
Optional Input Parameters
- 1:
– int64int32nag_int scalar
-
Default:
the dimension of the array
x.
, the number of observations.
Constraint:
.
- 2:
– int64int32nag_int scalar
Default:
The maximum number of iterations that should be used during the estimation.
Constraint:
.
Output Parameters
- 1:
– double scalar
-
The -estimate of the location argument .
- 2:
– double scalar
-
The
-estimate of the scale argument
, if
isigma was assigned the value
on entry, otherwise
sigma will contain the initial fixed value
.
- 3:
– double array
-
The Winsorized residuals.
- 4:
– int64int32nag_int scalar
-
The number of iterations that were used during the estimation.
- 5:
– double array
-
If
on entry,
wrk will contain the
observations in ascending order.
- 6:
– 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 . |
-
-
-
-
On entry, | all elements of the input array x are equal. |
-
-
sigma, the current estimate of
, is zero or negative. This error exit is very unlikely, although it may be caused by too large an initial value of
sigma.
-
-
The number of iterations required exceeds
maxit.
-
-
On completion of the iterations, the Winsorized residuals were all zero. This may occur when using the option with a redescending function, i.e., if , for some positive constant .
If the given value of
is too small, then the standardized residuals
, will be large and all the residuals may fall into the region for which
. This may incorrectly terminate the iterations thus making
theta and
sigma invalid.
Re-enter the function with a larger value of or with .
-
-
The value returned by the
chi function is negative.
-
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
Standard forms of the functions
and
are given in
Hampel et al. (1986),
Huber (1981) and
Marazzi (1987).
nag_univar_robust_1var_mestim (g07db) calculates
-estimates using some standard forms for
and
.
When you supply the initial values, care has to be taken over the choice of the initial value of
. If too small a value is chosen then initial values of the standardized residuals
will be large. If the redescending
functions are used, i.e.,
if
, for some positive constant
, then these large values are Winsorized as zero. If a sufficient number of the residuals fall into this category then a false solution may be returned, see page 152 of
Hampel et al. (1986).
Example
The following program reads in a set of data consisting of eleven observations of a variable .
The
psi and
chi functions used are Hampel's Piecewise Linear Function and Hubers
chi function respectively.
Using the following starting values various estimates of
and
are calculated and printed along with the number of iterations used:
(a) |
nag_univar_robust_1var_mestim_wgt (g07dc) determined the starting values, is estimated simultaneously. |
(b) |
You must supply the starting values, is estimated simultaneously. |
(c) |
nag_univar_robust_1var_mestim_wgt (g07dc) determined the starting values, is fixed. |
(d) |
You must supply the starting values, is fixed. |
Open in the MATLAB editor:
g07dc_example
function g07dc_example
fprintf('g07dc example results\n\n');
global dchi h1 h2 h3;
dchi = 1.5;
h1 = 1.5;
h2 = 3.0;
h3 = 4.5;
x = [13; 11; 16; 5; 3; 18; 9; 8; 6; 27; 7];
beta = 0.3892326;
tol = 0.0001;
isigma = int64([ 1 1 0 0]);
sigma = [-1 7 -1 7];
theta = [ 0 2 0 2];
fprintf(' Input parameters Output parameters\n');
fprintf(' isigma sigma theta tol sigma theta\n');
for j = 1:numel(theta)
fprintf('%3d %8.4f%8.4f%8.4f', isigma(j), sigma(j), theta(j), tol);
[thetaOut, sigmaOut, rs, nit, wrk, ifail] = ...
g07dc( ...
@chi, @psi, isigma(j), x, beta, theta(j), sigma(j), tol);
fprintf(' %8.4f%8.4f\n', sigmaOut, thetaOut);
end
function [result] = chi(t)
global dchi;
ps = min(dchi, abs(t));
result = ps*ps/2;
function [result] = psi(t)
global h1 h2 h3;
if abs(t) < h3
if abs(t) < h2
result=min(h1, abs(t));
else
result=h1*(h3-abs(t))/(h3-h2);
end
if t < 0
result = -result;
end
else
result=0;
end
g07dc example results
Input parameters Output parameters
isigma sigma theta tol sigma theta
1 -1.0000 0.0000 0.0001 6.3247 10.5487
1 7.0000 2.0000 0.0001 6.3249 10.5487
0 -1.0000 0.0000 0.0001 5.9304 10.4896
0 7.0000 2.0000 0.0001 7.0000 10.6500
PDF version (NAG web site
, 64-bit version, 64-bit version)
© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2015