naginterfaces.library.univar.robust_1var_mestim¶
- naginterfaces.library.univar.robust_1var_mestim(isigma, x, ipsi, c, h1, h2, h3, dchi, theta, sigma, tol, maxit=50)[source]¶
robust_1var_mestim
computes an -estimate of location with (optional) simultaneous estimation of the scale using Huber’s algorithm.For full information please refer to the NAG Library document for g07db
https://support.nag.com/numeric/nl/nagdoc_30.2/flhtml/g07/g07dbf.html
- Parameters
- isigmaint
The value assigned to determines whether is to be simultaneously estimated.
The estimation of is bypassed and is set equal to .
is estimated simultaneously.
- xfloat, array-like, shape
The vector of observations, .
- ipsiint
Which function is to be used.
.
Huber’s function.
Hampel’s piecewise linear function.
Andrew’s sine wave,
Tukey’s bi-weight.
- cfloat
If , must specify the parameter, , of Huber’s function. is not referenced if .
- h1float
If , , and must specify the parameters, , , and , of Hampel’s piecewise linear function. , and are not referenced if .
- h2float
If , , and must specify the parameters, , , and , of Hampel’s piecewise linear function. , and are not referenced if .
- h3float
If , , and must specify the parameters, , , and , of Hampel’s piecewise linear function. , and are not referenced if .
- dchifloat
, the parameter of the function. is not referenced if .
- thetafloat
If then must be set to the required starting value of the estimation of the location parameter . A reasonable initial value for will often be the sample mean or median.
- sigmafloat
The role of depends on the value assigned to , as follows:
if , must be assigned a value which determines the values of the starting points for the calculations of and . If then
robust_1var_mestim
will determine the starting points of and . Otherwise the value assigned to will be taken as the starting point for , and must be assigned a value before entry, see above;if , must be assigned a value which determines the value of , which is held fixed during the iterations, and the starting value for the calculation of . If ,
robust_1var_mestim
will determine the value of as the median absolute deviation adjusted to reduce bias (seerobust_1var_median()
) and the starting point for . Otherwise, the value assigned to will be taken as the value of and must be assigned a relevant value before entry, see above.- tolfloat
The relative precision for the final estimates. Convergence is assumed when the increments for , and are less than .
- maxitint, optional
The maximum number of iterations that should be used during the estimation.
- Returns
- thetafloat
The -estimate of the location parameter, .
- sigmafloat
Contains the -estimate of the scale parameter, , if was assigned the value on entry, otherwise will contain the initial fixed value .
- rsfloat, ndarray, shape
The Winsorized residuals.
- nitint
The number of iterations that were used during the estimation.
- wrkfloat, ndarray, shape
If on entry, will contain the observations in ascending order.
- Raises
- NagValueError
- (errno )
On entry, .
Constraint: , , , or .
- (errno )
On entry, .
Constraint: or .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, .
Constraint: .
- (errno )
On entry, , and .
Constraint: and .
- (errno )
On entry, .
Constraint: .
- (errno )
All elements of are equal.
- (errno )
Current estimate of is zero or negative: .
- (errno )
Number of iterations required exceeds : .
- (errno )
All winsorized residuals are zero.
- Notes
In the NAG Library the traditional C interface for this routine uses a different algorithmic base. Please contact NAG if you have any questions about compatibility.
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 parameter, and is a scale parameter. -estimators of and are given by the solution to the following system of equations:
where and are given functions, and is a constant, such that is an unbiased estimator when , for has a Normal distribution. Optionally, the second equation can be omitted and the first equation is solved for using an assigned value of .
The values of are known as the Winsorized residuals.
The following functions are available for and in
robust_1var_mestim
:Null Weights
Use of these null functions leads to the mean and standard deviation of the data.
Huber’s Function
Hampel’s Piecewise Linear Function
Andrew’s Sine Wave Function
otherwise
Tukey’s Bi-weight
otherwise
where , , , and are constants.
Equations (1) and (2) are solved by a simple iterative procedure suggested by Huber:
and
or
The initial values for and may either be user-supplied or calculated within
robust_1var_mestim
as the sample median and an estimate of based on the median absolute deviation respectively.robust_1var_mestim
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