Huber's Least Favourable Distribution
huberUC.RdDensity, distribution function, quantile function and random generation for Huber's least favourable distribution, see Huber and Ronchetti (2009).
Usage
dhuber(x, k = 0.862, mu = 0, sigma = 1, log = FALSE)
edhuber(x, k = 0.862, mu = 0, sigma = 1, log = FALSE)
rhuber(n, k = 0.862, mu = 0, sigma = 1)
qhuber(p, k = 0.862, mu = 0, sigma = 1, lower.tail = TRUE,
log.p = FALSE)
phuber(q, k = 0.862, mu = 0, sigma = 1, lower.tail = TRUE,
log.p = FALSE)Arguments
- x, q
numeric vector, vector of quantiles.
- p
vector of probabilities.
- n
number of random values to be generated. If
length(n) > 1then the length is taken to be the number required.- k
numeric. Borderline value of central Gaussian part of the distribution. This is known as the tuning constant, and should be positive. For example,
k = 0.862refers to a 20% contamination neighborhood of the Gaussian distribution. Ifk = 1.40then this is 5% contamination.- mu
numeric. distribution mean.
- sigma
numeric. Distribution scale (
sigma = 1defines the distribution in standard form, with standard Gaussian centre).- log
Logical. If
log = TRUEthen the logarithm of the result is returned.- lower.tail, log.p
Details
Details are given in huber2, the
VGAM family function for estimating the
parameters mu and sigma.
Value
dhuber gives out a vector of density values.
edhuber gives out a list with components val
(density values) and eps (contamination proportion).
rhuber gives out a vector of random numbers generated
by Huber's least favourable distribution.
phuber gives the distribution function,
qhuber gives the quantile function.
Author
Christian Hennig wrote [d,ed,r]huber()
(from smoothmest) and
slight modifications were made by T. W. Yee to
replace looping by vectorization and addition of the log
argument.
Arash Ardalan wrote [pq]huber(), and
two arguments for these were implemented by Kai Huang.
This helpfile was adapted from smoothmest.
Examples
set.seed(123456)
edhuber(1:5, k = 1.5)
#> $val
#> [1] 0.232871117 0.058879039 0.013137689 0.002931415 0.000654087
#>
#> $eps
#> [1] 0.03760623
#>
rhuber(5)
#> [1] 0.6909149 -0.5883181 -1.4595939 -1.2289721 -1.3205611
if (FALSE) mu <- 3; xx <- seq(-2, 7, len = 100) # Plot CDF and PDF
plot(xx, dhuber(xx, mu = mu), type = "l", col = "blue", las = 1,
main = "blue is density, orange is the CDF", ylab = "",
sub = "Purple lines are the 10,20,...,90 percentiles",
ylim = 0:1)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'y' in selecting a method for function 'plot': object 'mu' not found
abline(h = 0, col = "blue", lty = 2)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
lines(xx, phuber(xx, mu = mu), type = "l", col = "orange")
#> Error: object 'mu' not found
probs <- seq(0.1, 0.9, by = 0.1)
Q <- qhuber(probs, mu = mu)
#> Error: object 'mu' not found
lines(Q, dhuber(Q, mu = mu), col = "purple", lty = 3, type = "h")
#> Error: object 'Q' not found
lines(Q, phuber(Q, mu = mu), col = "purple", lty = 3, type = "h")
#> Error: object 'Q' not found
abline(h = probs, col = "purple", lty = 3)
#> Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...): plot.new has not been called yet
phuber(Q, mu = mu) - probs # Should be all 0s
#> Error: object 'Q' not found
# \dontrun{}