NAG Library Function Document
nag_robust_m_estim_1var_usr (g07dcc)
1 Purpose
nag_robust_m_estim_1var_usr (g07dcc) computes an -estimate of location with (optional) simultaneous estimation of scale, where you provide the weight functions.
2 Specification
#include <nag.h> |
#include <nagg07.h> |
void |
nag_robust_m_estim_1var_usr (
double |
(*chi)(double t,
Nag_Comm *comm),
|
|
double |
(*psi)(double t,
Nag_Comm *comm),
|
|
Integer isigma,
Integer n,
const double x[],
double beta,
double *theta,
double *sigma,
Integer maxit,
double tol,
double rs[],
Integer *nit,
Nag_Comm *comm,
NagError *fail) |
|
3 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_robust_m_estim_1var (g07dbc) as the sample median and an estimate of
based on the median absolute deviation respectively.
nag_robust_m_estim_1var_usr (g07dcc) is based upon function LYHALG within the ROBETH library, see
Marazzi (1987).
4 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
5 Arguments
- 1:
chi – function, supplied by the userExternal Function
chi must return the value of the weight function
for a given value of its argument. The value of
must be non-negative.
The specification of
chi is:
double |
chi (double t,
Nag_Comm *comm)
|
|
- 1:
t – doubleInput
On entry: the argument for which
chi must be evaluated.
- 2:
comm – Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to
chi.
- user – double *
- iuser – Integer *
- p – Pointer
The type Pointer will be
void *. Before calling nag_robust_m_estim_1var_usr (g07dcc) you may allocate memory and initialize these pointers with various quantities for use by
chi when called from nag_robust_m_estim_1var_usr (g07dcc) (see
Section 3.2.1.1 in the Essential Introduction).
- 2:
psi – function, supplied by the userExternal Function
psi must return the value of the weight function
for a given value of its argument.
The specification of
psi is:
double |
psi (double t,
Nag_Comm *comm)
|
|
- 1:
t – doubleInput
On entry: the argument for which
psi must be evaluated.
- 2:
comm – Nag_Comm *
Pointer to structure of type Nag_Comm; the following members are relevant to
psi.
- user – double *
- iuser – Integer *
- p – Pointer
The type Pointer will be
void *. Before calling nag_robust_m_estim_1var_usr (g07dcc) you may allocate memory and initialize these pointers with various quantities for use by
psi when called from nag_robust_m_estim_1var_usr (g07dcc) (see
Section 3.2.1.1 in the Essential Introduction).
- 3:
isigma – IntegerInput
On entry: 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:
n – IntegerInput
On entry: , the number of observations.
Constraint:
.
- 5:
x[n] – const doubleInput
On entry: the vector of observations, .
- 6:
beta – doubleInput
On entry: the value of the constant
of the chosen
chi function.
Constraint:
.
- 7:
theta – double *Input/Output
On entry: 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.
On exit: the -estimate of the location argument .
- 8:
sigma – double *Input/Output
On entry: 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_robust_m_estim_1var_usr (g07dcc) 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_robust_m_estim_1var_usr (g07dcc) will determine the value of
as the median absolute deviation adjusted to reduce bias (see
nag_median_1var (g07dac)) 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.
On exit: the
-estimate of the scale argument
, if
isigma was assigned the value
on entry, otherwise
sigma will contain the initial fixed value
.
- 9:
maxit – IntegerInput
On entry: the maximum number of iterations that should be used during the estimation.
Suggested value:
.
Constraint:
.
- 10:
tol – doubleInput
On entry: the relative precision for the final estimates. Convergence is assumed when the increments for
theta, and
sigma are less than
.
Constraint:
.
- 11:
rs[n] – doubleOutput
On exit: the Winsorized residuals.
- 12:
nit – Integer *Output
On exit: the number of iterations that were used during the estimation.
- 13:
comm – Nag_Comm *Communication Structure
-
The NAG communication argument (see
Section 3.2.1.1 in the Essential Introduction).
- 14:
fail – NagError *Input/Output
-
The NAG error argument (see
Section 3.6 in the Essential Introduction).
6 Error Indicators and Warnings
- NE_ALLOC_FAIL
-
Dynamic memory allocation failed.
- NE_BAD_PARAM
-
On entry, argument had an illegal value.
- NE_FUN_RET_VAL
-
The
chi function returned a negative value:
.
- NE_INT
-
On entry, .
Constraint: or .
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_INTERNAL_ERROR
-
An internal error has occurred in this function. Check the function call and any array sizes. If the call is correct then please contact
NAG for assistance.
- NE_REAL
-
On entry, .
Constraint: .
On entry, .
Constraint: .
- NE_REAL_ARRAY_ELEM_CONS
-
All elements of
x are equal.
- NE_SIGMA_NEGATIVE
-
Current estimate of
sigma is zero or negative:
.
- NE_TOO_MANY_ITER
-
Number of iterations required exceeds
maxit:
.
- NE_ZERO_RESID
-
All winsorized residuals are zero.
7 Accuracy
On successful exit the accuracy of the results is related to the value of
tol, see
Section 5.
8 Parallelism and Performance
nag_robust_m_estim_1var_usr (g07dcc) is threaded by NAG for parallel execution in multithreaded implementations of the NAG Library.
nag_robust_m_estim_1var_usr (g07dcc) makes calls to BLAS and/or LAPACK routines, which may be threaded within the vendor library used by this implementation. Consult the documentation for the vendor library for further information.
Please consult the
Users' Note for your implementation for any additional implementation-specific information.
Standard forms of the functions
and
are given in
Hampel et al. (1986),
Huber (1981) and
Marazzi (1987).
nag_robust_m_estim_1var (g07dbc) 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).
10 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_robust_m_estim_1var_usr (g07dcc) determined the starting values, is estimated simultaneously. |
(b) |
You must supply the starting values, is estimated simultaneously. |
(c) |
nag_robust_m_estim_1var_usr (g07dcc) determined the starting values, is fixed. |
(d) |
You must supply the starting values, is fixed. |
10.1 Program Text
Program Text (g07dcce.c)
10.2 Program Data
Program Data (g07dcce.d)
10.3 Program Results
Program Results (g07dcce.r)