Density, distribution function, quantile function, random generation, expected shortfall and expected value and variance for the generalized inverse gaussian distribution.
dgig(x, lambda = 1, chi = 1, psi = 1, logvalue = FALSE)pgig(q, lambda = 1, chi = 1, psi = 1, ...)
qgig(p, lambda = 1, chi = 1, psi = 1, method = c("integration", "splines"),
spline.points = 200, subdivisions = 200,
root.tol = .Machine$double.eps^0.5,
rel.tol = root.tol^1.5, abs.tol = rel.tol, ...)
rgig(n = 10, lambda = 1, chi = 1, psi = 1)
ESgig(alpha, lambda = 1, chi = 1, psi = 1, distr = c("return", "loss"), ...)
Egig(lambda, chi, psi, func = c("x", "logx", "1/x", "var"), check.pars = TRUE)
dgig
gives the density,
pgig
gives the distribution function,
qgig
gives the quantile function,
ESgig
gives the expected shortfall,
rgig
generates random deviates and
Egig
gives the expected value
of either x
, 1/x
, log(x)
or the variance if func
equals var
.
A vector of quantiles.
A vector of quantiles.
A vector of probabilities.
A vector of confidence levels.
Number of observations.
A shape and scale and parameter.
Shape and scale parameters. Must be positive.
If TRUE
the logarithm of the density will be returned.
Whether the ghyp-object specifies a return or a loss-distribution (see Details).
The number of subdivisions passed to integrate
when computing
the the distribution function pgig
.
The relative accuracy requested from integrate
.
The absolute accuracy requested from integrate
.
Determines which method is used when calculating quantiles.
The number of support points when computing the quantiles with the method “splines” instead of “integration”.
The tolerance of uniroot
.
The transformation function when computing the expected value.
x
is the expected value (default), log x
returns the
expected value of the logarithm of x
, 1/x
returns the
expected value of the inverse of x
and var
returns the
variance.
If TRUE
the parameters are checked first.
Arguments passed form ESgig
to qgig
.
David Luethi and Ester Pantaleo
qgig
computes the quantiles either by using the
“integration” method where the root of the distribution
function is solved or via “splines” which interpolates the
distribution function and solves it with uniroot
afterwards. The “integration” method is recommended when few
quantiles are required. If more than approximately 20 quantiles are
needed to be calculated the “splines” method becomes faster.
The accuracy can be controlled with an adequate setting of the
parameters rel.tol
, abs.tol
, root.tol
and
spline.points
.
rgig
relies on the C function with the same name kindly
provided by Ester Pantaleo and Robert B. Gramacy.
Egig
with func = "log x"
uses
grad
from the R package numDeriv. See
the package vignette for details regarding the expectation of GIG
random variables.
Dagpunar, J.S. (1989). An easily implemented generalised inverse Gaussian generator. Commun. Statist. -Simula., 18, 703--710.
Michael, J. R, Schucany, W. R, Haas, R, W. (1976). Generating random variates using transformations with multiple roots, The American Statistican, 30, 88--90.
dgig(1:40, lambda = 10, chi = 1, psi = 1)
qgig(1e-5, lambda = 10, chi = 1, psi = 1)
ESgig(c(0.19,0.3), lambda = 10, chi = 1, psi = 1, distr = "loss")
ESgig(alpha=c(0.19,0.3), lambda = 10, chi = 1, psi = 1, distr = "ret")
Egig(lambda = 10, chi = 1, psi = 1, func = "x")
Egig(lambda = 10, chi = 1, psi = 1, func = "var")
Egig(lambda = 10, chi = 1, psi = 1, func = "1/x")
Run the code above in your browser using DataLab