huber2 | R Documentation |
Weighted Huber Proposal 2 estimator of location and scatter.
huber2(x, w, k = 1.5, na.rm = FALSE, maxit = 50, tol = 1e-04, info = FALSE, k_Inf = 1e6, df_cor = TRUE)
x |
|
w |
|
k |
|
na.rm |
|
maxit |
|
tol |
|
info |
|
k_Inf |
|
df_cor |
|
Function huber2
computes the weighted Huber (1964) Proposal 2
estimates of location and scale.
The method is initialized by the weighted median (location) and the weighted interquartile range (scale).
The return value depends on info
:
info = FALSE
:estimate of mean or total [double]
info = TRUE
:a [list]
with items:
characteristic
[character]
,
estimator
[character]
,
estimate
[double]
,
variance
(default: NA
),
robust
[list]
,
residuals
[numeric vector]
,
model
[list]
,
design
(default: NA
),
[call]
The huber2
estimator is initialized by the weighted median and
the weighted (scaled) interquartile range. For unweighted data, this
estimator differs from hubers
in MASS,
which is initialized by mad
.
The difference between the estimators is usually negligible (for
sufficiently small values of tol
). See examples.
Huber, P. J. (1964). Robust Estimation of a Location Parameter. Annals of Mathematical Statistics 35, 73–101. doi: 10.1214/aoms/1177703732
data(workplace) # Weighted "Proposal 2" estimator of the mean huber2(workplace$employment, workplace$weight, k = 8) # More information on the estimate, i.e., info = TRUE m <- huber2(workplace$employment, workplace$weight, k = 8, info = TRUE) # Estimate of scale m$scale # Comparison with MASS::hubers (without weights). We make a copy of MASS::hubers library(MASS) hubers_mod <- hubers # Then we replace mad by the (scaled) IQR as initial scale estimator body(hubers_mod)[[7]][[3]][[2]] <- substitute(s0 <- IQR(y, type = 2) * 0.7413) # Define the numerical tolerance TOLERANCE <- 1e-8 # Comparison m1 <- huber2(workplace$payroll, rep(1, 142), tol = TOLERANCE) m2 <- hubers_mod(workplace$payroll, tol = TOLERANCE)$mu m1 / m2 - 1 # The absolute relative difference is < 4.0-09 (smaller than TOLERANCE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.