Safe (generalized) Huber M-Estimator of Location
(Generalized) Huber M-estimator of location with MAD scale, being
sensible also when the scale is zero where huber()
returns an error.
HuberM(x, k = 1.345, mu = median(x), s = mad(x, center = mu), na.rm = FALSE, conf.level = NA, ci.type = c("wald", "boot"), ...)
x |
numeric vector. |
k |
positive factor; the algorithm winsorizes at |
mu |
initial location estimator. |
s |
scale estimator held constant through the iterations. |
na.rm |
logical, indicating whether |
conf.level |
confidence level of the interval. If set to |
ci.type |
The type of confidence interval required. The value should be any subset
of the values |
... |
the dots are passed to the function |
The standard error is computed using the τ correction factor but no finite sample correction.
The original function is not exported, but can be accessed as DescTools::.huberM
.
If conf.level
is set to NA
then the result will be
|
a single numeric value |
and
if a conf.level
is provided, a named numeric vector with 3 elements:
huberm |
the estimate for location |
lwr.ci |
lower bound of the confidence interval |
upr.ci |
upper bound of the confidence interval |
Martin Maechler, building on the MASS code mentioned.
Andri Signorell <andri@signorell.net> (confidence intervals and interface)
Huber, P. J. (1981) Robust Statistics. Wiley.
HuberM(c(1:9, 1000)) mad (c(1:9, 1000)) set.seed(7) x <- c(round(rnorm(1000), 1), round(rnorm(50, m=10, sd = 10))) HuberM(x, conf.level=0.95) ## Not run: # scale zero HuberM(rep(9, 100)) mad (rep(9, 100)) # bootstrap confidence intervals HuberM(x, conf.level=0.95, ci.type="boot") ## End(Not run)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.