Learn R Programming

extraDistr (version 1.8.1)

Huber: "Huber density" distribution

Description

Density, distribution function, quantile function and random generation for the "Huber density" distribution.

Usage

dhuber(x, mu = 0, sigma = 1, epsilon = 1.345, log = FALSE)
phuber(q, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE)
qhuber(p, mu = 0, sigma = 1, epsilon = 1.345, lower.tail = TRUE, log.p = FALSE)
rhuber(n, mu = 0, sigma = 1, epsilon = 1.345)

Arguments

x, q
vector of quantiles.
mu, sigma, epsilon
location, and scale, and shape parameters. Scale and shape must be positive.
log, log.p
logical; if TRUE, probabilities p are given as log(p).
lower.tail
logical; if TRUE (default), probabilities are $P[X \le x]$ otherwise, $P[X > x]$.
p
vector of probabilities.
n
number of observations. If length(n) > 1, the length is taken to be the number required.

Details

Huber density is connected to Huber loss and can be defined as:

$$ f(x) = \frac{1-\epsilon}{\sqrt{2\pi}} e^{-\rho_k(x)} $$

where

$$ \rho_k(x) = \left\{\begin{array}{ll} \frac{1}{2} x^2 & |x|\le k \\ k|x|- \frac{1}{2} k^2 & |x|>k \end{array}\right. $$

and $\epsilon$ satisfies

$$ \frac{2\phi(k)}{k} - 2\Phi(-k) = \frac{\epsilon}{1-\epsilon} $$

References

Huber, P.J. (1964). Robust Estimation of a Location Parameter. Annals of Statistics, 53(1), 73-101.

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

Schumann, D. (2009). Robust Variable Selection. ProQuest.

Examples

Run this code

x <- rhuber(1e5, 5, 2, 3)
xx <- seq(-20, 20, by = 0.1)
hist(x, 100, freq = FALSE)
lines(xx, dhuber(xx, 5, 2, 3), col = "red")
hist(phuber(x, 5, 2, 3))
plot(ecdf(x))
lines(xx, phuber(xx, 5, 2, 3), col = "red", lwd = 2)

Run the code above in your browser using DataLab