|
NAG[g02hac] NAG[nag_robust_m_regsn_estim] - Robust regression, standard -estimates
|
|
Calling Sequence
g02hac(regtype, psifun, sigma_est, covmat_est, x, y, cpsi, hpsi, cucv, dchi, theta, sigma, c, rs, wt, tol, print_iter, algorithm_info, 'n'=n, 'm'=m, 'tdx'=tdx, 'tdc'=tdc, 'max_iter'=max_iter, 'outfile'=outfile, 'fail'=fail)
nag_robust_m_regsn_estim(. . .)
Parameters
|
regtype - String;
|
|
|
On entry: specifies the type of regression to be performed.
|
|
Huber type regression.
|
|
Mallows type regression with Maronna's proposed weights.
|
|
Schweppe type regression with Krasker–Welsch weights.
|
|
Constraint: "Nag_HuberReg", "Nag_MallowsReg" or "Nag_SchweppeReg". .
|
|
|
psifun - String;
|
|
|
On entry: specifies which function is to be used.
|
|
, i.e., least-squares.
|
|
Huber's function.
|
|
Hampel's piecewise linear function.
|
|
Andrew's sine wave.
|
|
Tukey's bi-weight.
|
|
Constraint: "Nag_Lsq", "Nag_HuberFun", "Nag_HampelFun", "Nag_AndrewFun" or "Nag_TukeyFun". .
|
|
|
sigma_est - String;
|
|
|
On entry: specifies how is to be estimated.
|
|
is estimated by median absolute deviation of residuals.
|
|
is held constant at its initial value.
|
|
Constraint: "Nag_SigmaRes", "Nag_SigmaConst" or "Nag_SigmaChi". .
|
|
|
covmat_est - String;
|
|
|
If then covmat_est is not referenced.
|
|
Constraint: "Nag_CovMatAve" or "Nag_CovMatObs". .
|
|
|
x - Matrix(1..n, 1..tdx, datatype=float[8], order=C_order);
|
|
|
On exit: if , then during calculations the elements of x will be transformed as described in Section [Description]. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input x and the output x. Otherwise x is unchanged.
|
|
|
y - Vector(1..n, datatype=float[8]);
|
|
|
On exit: if , then during calculations the elements of y will be transformed as described in Section [Description]. Before exit the inverse transformation will be applied. As a result there may be slight differences between the input y and the output y. Otherwise y is unchanged.
|
|
|
cpsi - float;
|
|
|
Constraint: if then . .
|
|
|
hpsi - Vector(1.., datatype=float[8]);
|
|
|
|
cucv - float;
|
|
|
If then cucv must specify the value of the function for the Krasker–Welsch weights.
|
|
If then cucv is not referenced.
|
|
if , ;
|
|
if , .
|
|
|
dchi - float;
|
|
|
On entry: the constant, , of the function.
|
|
dchi is referenced only if and .
|
|
|
theta - Vector(1..m, datatype=float[8]);
|
|
|
On entry: starting values of the argument vector . These may be obtained from least-squares regression.
|
|
|
sigma - assignable;
|
|
|
Note: On exit the variable sigma will have a value of type float.
|
|
On entry: a starting value for the estimation of .
|
|
sigma should be approximately the standard deviation of the residuals from the model evaluated at the value of given by theta on entry.
|
|
On exit: sigma contains the final estimate of , unless .
|
|
Constraint: . .
|
|
|
c - Matrix(1..m, 1..tdc, datatype=float[8], order=C_order);
|
|
|
|
rs - Vector(1..n, datatype=float[8]);
|
|
|
|
wt - Vector(1..n, datatype=float[8]);
|
|
|
|
tol - float;
|
|
|
It is advisable for tol to be greater than machine precision.
|
|
Constraint: . .
|
|
|
print_iter - integer;
|
|
|
On entry: the amount of information that is printed on each iteration.
|
|
No information is printed.
|
|
|
algorithm_info - Vector(1.., datatype=float[8]);
|
|
|
On exit: elements of info contain the following values:
|
|
if ,
|
|
or if ,
|
|
number of iterations used to calculate .
|
|
, the rank of the weighted least-squares equations.
|
|
|
'n'=n - integer; (optional)
|
|
|
Default value: the first dimension of the arrays x, y, rs, wt.
|
|
On entry: the number of observations, .
|
|
Constraint: . .
|
|
|
'm'=m - integer; (optional)
|
|
|
Default value: the first dimension of the arrays theta, c and the second dimension of the arrays theta, cthe arrays x, c.
|
|
On entry: the number , of independent variables.
|
|
Constraint: . .
|
|
|
'tdx'=tdx - integer; (optional)
|
|
|
On entry: the second dimension of the array x as declared in the function from which nag_robust_m_regsn_estim (g02hac) is called.
|
|
Constraint: . .
|
|
|
'tdc'=tdc - integer; (optional)
|
|
|
On entry: the second dimension of the array c as declared in the function from which nag_robust_m_regsn_estim (g02hac) is called.
|
|
Constraint: . .
|
|
|
'max_iter'=max_iter - integer; (optional)
|
|
|
Suggested value: (default: ) A value of should be adequate for most uses.
|
|
Constraint: . .
|
|
|
'outfile'=outfile - character; (optional)
|
|
|
On entry: The name of a file to which intermediate or diagnostic output should be appended. If a value is not provided for this parameter then the behaviour of this routine is platform dependent. Usually all output will be suppressed, however on some platforms output will be produced and will be displayed in the Maple session.
|
|
|
'fail'=fail - table; (optional)
|
|
|
The NAG error argument, see the documentation for NagError.
|
|
|
|
Description
|
|
|
Purpose
|
|
nag_robust_m_regsn_estim (g02hac) performs bounded influence regression (M-estimates). Several standard methods are available.
|
|
Description
|
|
For the linear regression model
|
where is a vector of length of the dependent variable,
|
|
is a vector of length of unknown arguments,
|
nag_robust_m_regsn_estim (g02hac) calculates the M-estimates given by the solution, , to the equation
(1)
|
is a suitable weight function,
|
|
are suitable weights,
|
|
and may be estimated at each iteration by the median absolute deviation of the residuals:
|
or as the solution to:
for suitable weight function , where and are constants, chosen so that the estimator of is asymptotically unbiased if the errors, , have a Normal distribution. Alternatively may be held at a constant value.
The above describes the Schweppe type regression. If the are assumed to equal 1 for all then Huber type regression is obtained. A third type, due to Mallows, replaces (1) by
This may be obtained by use of the transformations
(see Marazzi (1987a)).
For Huber and Schweppe type regressions, is the 75th percentile of the standard Normal distribution. For Mallows type regression is the solution to
where is the standard Normal cumulative distribution function.
is given by:
where is the standard Normal density, i.e.,
The calculation of the estimates of can be formulated as an iterative weighted least-squares problem with a diagonal weight matrix given by
where is the derivative of at the point .
The value of at each iteration is given by the weighted least-squares regression of on . This is carried out by first transforming the and by
and then obtaining the solution of the resulting least squares problem. If is of full column rank then an orthogonal-triangular (QR) decomposition is used, if not, a singular value decomposition is used.
The following functions are available for and in nag_robust_m_regsn_estim (g02hac).
|
this gives least-squares regression.
|
|
c. Hampel's Piecewise Linear Function
|
|
d. Andrew's Sine Wave Function
|
where , , , , and are given constants.
Several schemes for calculating weights have been proposed, see Hampel et al. (1986) and Marazzi (1987a). 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
|
and is a suitable function.
|
The weights are then calculated as
for a suitable function .
nag_robust_m_regsn_estim (g02hac) finds using the iterative procedure
where ,
and
and and are bounds set at 0.9.
Two weights are available in nag_robust_m_regsn_estim (g02hac):
|
These are for use with Schweppe type regression.
|
|
Maronna's proposed weights
|
|
These are for use with Mallows type regression.
|
Finally the asymptotic variance-covariance matrix, , of the estimates is calculated.
For Huber type regression
where
See Huber (1981) and Marazzi (1987b).
For Mallows and Schweppe type regressions is of the form
where and .
is a diagonal matrix such that the th element approximates in the Schweppe case and in the Mallows case.
is a diagonal matrix such that the th element approximates in the Schweppe case and in the Mallows case.
Two approximations are available in nag_robust_m_regsn_estim (g02hac):
|
Average over the
|
|
Replace expected value by observed
|
See Hampel et al. (1986) and Marazzi (1987b).
|
Note: there is no explicit provision in the function for a constant term in the regression model. However, the addition of a dummy variable whose value is 1.0 for all observations will produce a value of corresponding to the usual constant term.
|
nag_robust_m_regsn_estim (g02hac) is based on routines in ROBETH, see Marazzi (1987a).
|
|
Error Indicators and Warnings
|
|
"NE_2_INT_ARG_GE"
On entry, while . These arguments must satisfy .
"NE_ALLOC_FAIL"
Dynamic memory allocation failed.
"NE_BAD_HAMPEL_PSI_FUN"
On entry, and , and . For this value of psifun, the elements of hpsi must satisfy the condition and .
"NE_BAD_PARAM"
On entry, argument regtype had an illegal value.
"NE_BETA1_ITER_EXCEEDED"
The number of iterations required to calculate exceeds max_iter. This is only applicable if and .
"NE_COV_MAT_FACTOR_ZERO"
In calculating the correlation factor for the asymptotic variance-covariance matrix, the factor for covariance matrix . For this error, either the value of
|
or ,
|
|
or .
|
|
See Section [Further Comments]. In this case c is returned as . (This is only applicable if ).
|
"NE_ERR_DOF_LEQ_ZERO"
, rank of . The degrees of freedom for error, (rank of x) must be .
"NE_ESTIM_SIGMA_ZERO"
The estimated value of was during an iteration.
"NE_INT_ARG_LE"
On entry, max_iter must not be less than or equal to 0: .
"NE_INT_ARG_LT"
On entry, n must not be less than 2: .
"NE_INVALID_DCHI_FUN"
On entry, , and . For these values of psifun and sigma_est, dchi must be .
"NE_INVALID_HUBER_FUN"
On entry, and . For this value of psifun, cpsi must be .
"NE_INVALID_MALLOWS_REG_C"
On entry, , and . For this value of regtype, cucv must be .
"NE_INVALID_SCHWEPPE_REG_C"
On entry, , and . For this value of regtype, cucv must be .
"NE_LSQ_FAIL_CONV"
The iterations to solve the weighted least-squares equations failed to converge.
"NE_NOT_APPEND_FILE"
Cannot open file for appending.
"NE_NOT_CLOSE_FILE"
Cannot close file .
"NE_REAL_ARG_LE"
On entry, sigma must not be less than or equal to 0.0: .
"NE_REG_MAT_SINGULAR"
Failure to invert matrix while calculating covariance. If , then is almost singular. If , then is singular or almost singular. This may be due to too many diagonal elements of the matrix being zero, see Section [Further Comments].
"NE_THETA_ITER_EXCEEDED"
The number of iterations required to calculate and exceeds max_iter. In this case, on exit.
"NE_VAR_THETA_LEQ_ZERO"
The estimated variance for an element of . In this case the diagonal element of c will contain the negative variance and the above diagonal elements in the row and the column corresponding to the element will be returned as zero. This error may be caused by rounding errors or too many of the diagonal elements of p being zero. See Section [Further Comments].
"NE_WT_ITER_EXCEEDED"
The number of iterations required to calculate the weights exceeds max_iter. This is only applicable if .
"NE_WT_LSQ_NOT_FULL_RANK"
The weighted least-squares equations are not of full rank.
|
|
Accuracy
|
|
The precision of the estimates is determined by tol, see Section [Parameters]. As a more stable method is used to calculate the estimates of than is used to calculate the covariance matrix, it is possible for the least-squares equations to be of full rank but the matrix to be too nearly singular to be inverted.
|
|
Further Comments
|
|
In cases when it is important for the value of sigma to be of a reasonable magnitude. Too small a value may cause too many of the winsorized residuals, i.e., to be zero or a value of , used to estimate the asymptotic covariance matrix, to be zero. This can lead to errors with the one of following errors being raised:
|
NE_REG_MAT_SINGULAR (if ),
|
|
NE_COV_MAT_FACTOR_ZERO (if )NE_VAR_THETA_LEQ_ZERO.
|
|
|
|
Examples
|
|
>
|
regtype := "Nag_SchweppeReg":
psifun := "Nag_HampelFun":
sigma_est := "Nag_SigmaChi":
covmat_est := "Nag_CovMatObs":
n := 8:
m := 3:
tdx := 3:
cpsi := 0:
cucv := 3:
dchi := 1.5:
sigma := 1:
tdc := 3:
tol := 5e-05:
max_iter := 50:
print_iter := 0:
x := Matrix([[1, -1, -1], [1, -1, 1], [1, 1, -1], [1, 1, 1], [1, -2, 0], [1, 0, -2], [1, 2, 0], [1, 0, 2]], datatype=float[8], order='C_order'):
y := Vector([2.1, 3.6, 4.5, 6.1, 1.3, 1.9, 6.7, 5.5], datatype=float[8]):
hpsi := Vector([1.5, 3, 4.5], datatype=float[8]):
theta := Vector([0, 0, 0], datatype=float[8]):
c := Matrix(3, 3, datatype=float[8], order='C_order'):
rs := Vector(8, datatype=float[8]):
wt := Vector(8, datatype=float[8]):
algorithm_info := Vector(4, datatype=float[8]):
NAG:-g02hac(regtype, psifun, sigma_est, covmat_est, x, y, cpsi, hpsi, cucv, dchi, theta, sigma, c, rs, wt, tol, print_iter, algorithm_info, 'n' = n, 'm' = m, 'tdx' = tdx, 'tdc' = tdc, 'max_iter' = max_iter):
|
|
|
See Also
|
|
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 (1987a) 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
Marazzi A (1987b) Subroutines for robust and bounded influence regression in ROBETH Cah. Rech. Doc. IUMSP, No. 3 ROB 2 Institut Universitaire de Médecine Sociale et Préventive, Lausanne
g02 Chapter Introduction.
NAG Toolbox Overview.
NAG Web Site.
|
|