DescTools (version 0.99.11)

HuberM: Safe (generalized) Huber M-Estimator of Location

Description

(Generalized) Huber M-estimator of location with MAD scale, being sensible also when the scale is zero where huber() returns an error.

Usage

HuberM(x, k = 1.5, mu = median(x), s = mad(x, center = mu), 
       na.rm = FALSE, conf.level = NA, ci.type = c("wald", "boot"), ...)

Arguments

x
numeric vector.
k
positive factor; the algorithm winsorizes at k standard deviations.
mu
initial location estimator.
s
scale estimator held constant through the iterations.
na.rm
logical, indicating whether NA values should be stripped before the computation proceeds. Defaults to FALSE.
conf.level
confidence level of the interval. If set to NA (which is the default) no confidence interval will be calculated.
ci.type
The type of confidence interval required. The value should be any subset of the values "classic", "norm", "basic", "stud", "perc" or "bca" ("all" which would
...
the dots are passed to the function boot, when confidence intervalls are calculated.

Value

  • 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:
  • hubermthe estimate
  • lwr.cilower bound of the confidence interval
  • upr.ciupper bound of the confidence interval

concept

robust location

Details

The standard error is computed using the $\tau$ correction factor but no finite sample correction.

References

Huber, P. J. (1981) Robust Statistics. Wiley.

See Also

hubers (and huber) in package MASS; mad.

Examples

Run this code
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)


# scale zero
HuberM(rep(9, 100))
mad   (rep(9, 100))

# bootstrap confidence intervals
HuberM(x, conf.level=0.95, ci.type="boot")

Run the code above in your browser using DataCamp Workspace