huber2 {robsurvey} | R Documentation |
Weighted Huber Proposal 2 Estimator
Description
Weighted Huber Proposal 2 estimator of location and scatter.
Usage
huber2(x, w, k = 1.5, na.rm = FALSE, maxit = 50, tol = 1e-04, info = FALSE,
k_Inf = 1e6, df_cor = TRUE)
Arguments
x |
|
w |
|
k |
|
na.rm |
|
maxit |
|
tol |
|
info |
|
k_Inf |
|
df_cor |
|
Details
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).
Value
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]
-
Comparison
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.
References
Huber, P. J. (1964). Robust Estimation of a Location Parameter. Annals of Mathematical Statistics 35, 73–101. doi:10.1214/aoms/1177703732
Examples
head(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)