| GeneralizedHyperbolicDistribution | R Documentation |
Density function, distribution function, quantiles and random number
generation for the generalized hyperbolic distribution, with
parameters \alpha (tail), \beta (skewness),
\delta (peakness), \mu (location) and
\lambda (shape).
dghyp(x, mu = 0, delta = 1, alpha = 1, beta = 0, lambda = 1,
param = c(mu, delta, alpha, beta, lambda))
pghyp(q, mu = 0, delta = 1, alpha = 1, beta = 0, lambda = 1,
param = c(mu, delta, alpha, beta, lambda),
lower.tail = TRUE, subdivisions = 100,
intTol = .Machine$double.eps^0.25, valueOnly = TRUE, ...)
qghyp(p, mu = 0, delta = 1, alpha = 1, beta = 0, lambda = 1,
param = c(mu, delta, alpha, beta, lambda),
lower.tail = TRUE, method = c("spline","integrate"),
nInterpol = 501, uniTol = .Machine$double.eps^0.25,
subdivisions = 100, intTol = uniTol, ...)
rghyp(n, mu = 0, delta = 1, alpha = 1, beta = 0, lambda = 1,
param = c(mu, delta, alpha, beta, lambda))
ddghyp(x, mu = 0, delta = 1, alpha = 1, beta = 0, lambda = 1,
param = c(mu, delta, alpha, beta, lambda))
x, q |
Vector of quantiles. |
p |
Vector of probabilities. |
n |
Number of random variates to be generated. |
mu |
Location parameter |
delta |
Scale parameter |
alpha |
Tail parameter |
beta |
Skewness parameter |
lambda |
Shape parameter |
param |
Specifying the parameters as a vector of the form |
method |
Character. If |
lower.tail |
Logical. If |
subdivisions |
The maximum number of subdivisions used to integrate the density and determine the accuracy of the distribution function calculation. |
intTol |
Value of |
valueOnly |
Logical. If |
nInterpol |
Number of points used in |
uniTol |
Value of |
... |
Passes additional arguments to |
Users may either specify the values of the parameters individually or
as a vector. If both forms are specified, then the values specified by
the vector param will overwrite the other ones. In addition the
parameter values are examined by calling the function
ghypCheckPars to see if they are valid.
The density function is
f(x)=c(\lambda,\alpha,\beta,\delta)\times%
\frac{K_{\lambda-1/2}(\alpha\sqrt{\delta^2+(x-\mu)^2})}%
{(\frac{\sqrt{\delta^2+(x-\mu)^2}}{\alpha})^{1/2-\lambda}}%
e^{\beta(x-\mu)}
where K_\nu() is the modified Bessel function of the
third kind with order \nu, and
c(\lambda,\alpha,\beta,\delta)=%
\frac{(\frac{\sqrt{\alpha^2-\beta^2}}{\delta})^\lambda}%
{\sqrt{2\pi}K_\lambda(\delta\sqrt{\alpha^2-\beta^2})}
Use ghypChangePars to convert from the
(\rho, \zeta),
(\xi, \chi),
(\bar\alpha, \bar\beta), or
(\pi, \zeta) parameterizations
to the (\alpha, \beta) parameterization used
above.
pghyp uses the function integrate to
numerically integrate the density function. The integration is from
-Inf to x if x is to the left of the mode, and
from x to Inf if x is to the right of the
mode. The probability calculated this way is subtracted from 1 if
required. Integration in this manner appears to make calculation of
the quantile function more stable in extreme cases.
Calculation of quantiles using qghyp permits the use of two
different methods. Both methods use uniroot to find the value
of x for which a given q is equal F(x) where F
denotes the cumulative distribution function. The difference is in how
the numerical approximation to F is obtained. The obvious
and more accurate method is to calculate the value of F(x)
whenever it is required using a call to pghyp. This is what
is done if the method is specified as "integrate". It is clear
that the time required for this approach is roughly linear in the
number of quantiles being calculated. A Q-Q plot of a large data set
will clearly take some time. The alternative (and default) method is
that for the major part of the distribution a spline approximation to
F(x) is calculated and quantiles found using uniroot with
this approximation. For extreme values (for which the tail probability
is less than 10^{-7}), the integration method is still
used even when the method specifed is "spline".
If accurate probabilities or quantiles are required, tolerances
(intTol and uniTol) should be set to small values, say
10^{-10} or 10^{-12} with method
= "integrate". Generally then accuracy might be expected to be at
least 10^{-9}. If the default values of the functions
are used, accuracy can only be expected to be around
10^{-4}. Note that on 32-bit systems
.Machine$double.eps^0.25 = 0.0001220703 is a typical value.
dghyp gives the density function, pghyp gives the
distribution function, qghyp gives the quantile function and
rghyp generates random variates.
An estimate of the accuracy of the approximation to the distribution
function can be found by setting valueOnly = FALSE in the call to
pghyp which returns a list with components value and
error.
ddghyp gives the derivative of dghyp.
David Scott d.scott@auckland.ac.nz
Barndorff-Nielsen, O., and Blæsild, P (1983). Hyperbolic distributions. In Encyclopedia of Statistical Sciences, eds., Johnson, N. L., Kotz, S., and Read, C. B., Vol. 3, pp. 700–707.-New York: Wiley.
Bibby, B. M., and Sörenson,M. (2003). Hyperbolic processes in finance. In Handbook of Heavy Tailed Distributions in Finance,ed., Rachev, S. T. pp. 212–248. Elsevier Science B.~V.
Dagpunar, J.S. (1989). An easily implemented generalised inverse Gaussian generator Commun. Statist.-Simula., 18, 703–710.
Prause, K. (1999) The generalized hyperbolic models: Estimation, financial derivatives and risk measurement. PhD Thesis, Mathematics Faculty, University of Freiburg.
dhyperb for the hyperbolic distribution,
dgig for the generalized inverse Gaussian distribution,
safeIntegrate,
integrate for its shortfalls, also
splinefun, uniroot and
ghypChangePars for changing parameters to the
(\alpha,\beta) parameterization.
param <- c(0, 1, 3, 1, 1/2)
ghypRange <- ghypCalcRange(param = param, tol = 10^(-3))
par(mfrow = c(1, 2))
### curves of density and distribution
curve(dghyp(x, param = param), ghypRange[1], ghypRange[2], n = 1000)
title("Density of the \n Generalized Hyperbolic Distribution")
curve(pghyp(x, param = param), ghypRange[1], ghypRange[2], n = 500)
title("Distribution Function of the \n Generalized Hyperbolic Distribution")
### curves of density and log density
par(mfrow = c(1, 2))
data <- rghyp(1000, param = param)
curve(dghyp(x, param = param), range(data)[1], range(data)[2],
n = 1000, col = 2)
hist(data, freq = FALSE, add = TRUE)
title("Density and Histogram of the\n Generalized Hyperbolic Distribution")
DistributionUtils::logHist(data,
main = "Log-Density and Log-Histogram of\n the Generalized Hyperbolic Distribution")
curve(log(dghyp(x, param = param)),
range(data)[1], range(data)[2],
n = 500, add = TRUE, col = 2)
### plots of density and derivative
par(mfrow = c(2, 1))
curve(dghyp(x, param = param), ghypRange[1], ghypRange[2], n = 1000)
title("Density of the\n Generalized Hyperbolic Distribution")
curve(ddghyp(x, param = param), ghypRange[1], ghypRange[2], n = 1000)
title("Derivative of the Density of the\n Generalized Hyperbolic Distribution")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.