Density, cumulative distribution, quantile functions and random number generation for the Asymmetric Laplace distribution with the location parameter mu, Mean Absolute Error (or Mean Absolute Deviation) equal to 2 scale and asymmetry parameter alpha.
dalaplace(q, mu = 0, scale = 1, alpha = 0.5, log = FALSE)palaplace(q, mu = 0, scale = 1, alpha = 0.5)
qalaplace(p, mu = 0, scale = 1, alpha = 0.5)
ralaplace(n = 1, mu = 0, scale = 1, alpha = 0.5)
vector of quantiles.
vector of location parameters (means).
vector of scale parameters.
value of asymmetry parameter. Varies from 0 to 1.
if TRUE
, then probabilities are returned in
logarithms.
vector of probabilities.
number of observations. Should be a single number.
Depending on the function, various things are returned (usually either vector or scalar):
dalaplace
returns the density function value for the
provided parameters.
palaplace
returns the value of the cumulative function
for the provided parameters.
qalaplace
returns quantiles of the distribution. Depending
on what was provided in p
, mu
and scale
, this
can be either a vector or a matrix, or an array.
ralaplace
returns a vector of random variables
generated from the Laplace distribution. Depending on what was
provided in mu
and scale
, this can be either a vector
or a matrix or an array.
When mu=0 and scale=1, the Laplace distribution becomes standardized. The distribution has the following density function:
f(x) = alpha (1-alpha) / scale exp(-(x-mu)/scale (alpha - I(x<=mu))),
where I(.) is the indicator function (equal to 1 if the condition is satisfied and zero otherwise).
When alpha=0.5, then the distribution becomes Symmetric Laplace, where scale = 1/2 MAE.
This distribution function aligns with the quantile estimates of parameters (Geraci & Bottai, 2007).
Finally, both palaplace
and qalaplace
are returned for
the lower tail of the distribution.
Geraci Marco, Bottai Matteo (2007). Quantile regression for longitudinal data using the asymmetric Laplace distribution. Biostatistics (2007), 8, 1, pp. 140-154 https://doi.org/10.1093/biostatistics/kxj039
Yu, K., & Zhang, J. (2005). A three-parameter asymmetric laplace distribution and its extension. Communications in Statistics - Theory and Methods, 34, 1867-1879. https://doi.org/10.1080/03610920500199018
# NOT RUN {
x <- dalaplace(c(-100:100)/10, 0, 1, 0.2)
plot(x, type="l")
x <- palaplace(c(-100:100)/10, 0, 1, 0.2)
plot(x, type="l")
qalaplace(c(0.025,0.975), 0, c(1,2), c(0.2,0.3))
x <- ralaplace(1000, 0, 1, 0.2)
hist(x)
# }
Run the code above in your browser using DataLab