na.rm: [logical] indicating whether NA values should be removed before the computation proceeds (default: FALSE).
maxit: [integer] maximum number of iterations to use (default: 50).
tol: [double] numerical tolerance criterion to stop the iterations (default: 1e-04).
info: [logical] indicating whether additional information should be returned (default: FALSE).
k_Inf: [integer] numerical value that represents Inf
(default: 1e+06).
df_cor: [logical] if TRUE, the degrees of freedom of the estimate of scale is adjusted (default: TRUE).
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).
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.
Huber, P. J. (1964). Robust Estimation of a Location Parameter. Annals of Mathematical Statistics 35 , 73--101. tools:::Rd_expr_doi("10.1214/aoms/1177703732")
Examples
head(workplace)# Weighted "Proposal 2" estimator of the meanhuber2(workplace$employment, workplace$weight, k =8)# More information on the estimate, i.e., info = TRUEm <- huber2(workplace$employment, workplace$weight, k =8, info =TRUE)# Estimate of scalem$scale
# Comparison with MASS::hubers (without weights). We make a copy of MASS::huberslibrary(MASS)hubers_mod <- hubers
# Then we replace mad by the (scaled) IQR as initial scale estimatorbody(hubers_mod)[[7]][[3]][[2]]<- substitute(s0 <- IQR(y, type =2)*0.7413)# Define the numerical toleranceTOLERANCE <-1e-8# Comparisonm1 <- 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)