Learn R Programming

HyperbolicDist (version 0.6-5)

GeneralizedHyperbolic: Generalized Hyperbolic Distribution

Description

Density function, distribution function, quantiles and random number generation for the generalized hyperbolic distribution with parameter vector Theta. Utility routines are included for the derivative of the density function and to find suitable break points for use in determining the distribution function.

Usage

dghyp(x, Theta)
pghyp(q, Theta, small = 10^(-6), tiny = 10^(-10),
      deriv = 0.3, subdivisions = 100, accuracy = FALSE, ...)
qghyp(p, Theta, small = 10^(-6), tiny = 10^(-10),
      deriv = 0.3, nInterpol = 100, subdivisions = 100, ...)
rghyp(n, Theta)
ddghyp(x, Theta)
ghypBreaks(Theta, small = 10^(-6), tiny = 10^(-10), deriv = 0.3, ...)

Value

dghyp gives the density, 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 may be found by setting

accuracy=TRUE in the call to pghyp which then returns a list with components value and error.

ddghyp gives the derivative of dghyp.

ghypBreaks returns a list with components:

xTiny

Value such that probability to the left is less than tiny.

xSmall

Value such that probability to the left is less than small.

lowBreak

Point to the left of the mode such that the derivative of the density is deriv times its maximum value on that side of the mode.

highBreak

Point to the right of the mode such that the derivative of the density is deriv times its maximum value on that side of the mode.

xLarge

Value such that probability to the right is less than small.

xHuge

Value such that probability to the right is less than tiny.

modeDist

The mode of the given generalized hyperbolic distribution.

Arguments

x,q

Vector of quantiles.

p

Vector of probabilities.

n

Number of observations to be generated.

Theta

Parameter vector taking the form c(lambda,alpha,beta,delta,mu).

small

Size of a small difference between the distribution function and zero or one. See Details.

tiny

Size of a tiny difference between the distribution function and zero or one. See Details.

deriv

Value between 0 and 1. Determines the point where the derivative becomes substantial, compared to its maximum value. See Details.

accuracy

Uses accuracy calculated by~integrate to try and determine the accuracy of the distribution function calculation.

subdivisions

The maximum number of subdivisions used to integrate the density returning the distribution function.

nInterpol

The number of points used in qghyp for cubic spline interpolation (see splinefun) of the distribution function.

...

Passes arguments to uniroot. See Details.

Author

David Scott d.scott@auckland.ac.nz, Richard Trendall

Details

The generalized hyperbolic distribution has density

$$f(x)=c(\lambda,\alpha,\beta,\delta)\times% \frac{K_{\lambda-1/2}(\alpha\sqrt{\delta^2+(x-\mu)^2})}% {(\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{(\sqrt{\alpha^2-\beta^2}/\delta)^\lambda}% {\sqrt{2\pi}K_\lambda(\delta\sqrt{\alpha^2-\beta^2})}$$

Use ghypChangePars to convert from the \((\zeta, \rho)\), \((\xi,\chi)\), or \((\bar\alpha,\bar\beta)\) parameterisations to the \((\alpha, \beta)\) parameterisation used above.

pghyp breaks the real line into eight regions in order to determine the integral of dghyp. The break points determining the regions are found by ghypBreaks, based on the values of small, tiny, and deriv. In the extreme tails of the distribution where the probability is tiny according to ghypCalcRange, the probability is taken to be zero. In the inner part of the distribution, the range is divided in 6 regions, 3 above the mode, and 3 below. On each side of the mode, there are two break points giving the required three regions. The outer break point is where the probability in the tail has the value given by the variable small. The inner break point is where the derivative of the density function is deriv times the maximum value of the derivative on that side of the mode. In each of the 6 inner regions the numerical integration routine safeIntegrate (which is a wrapper for integrate) is used to integrate the density dghyp.

qghyp use the breakup of the real line into the same 8 regions as pghyp. For quantiles which fall in the 2 extreme regions, the quantile is returned as -Inf or Inf as appropriate. In the 6 inner regions splinefun is used to fit values of the distribution function generated by pghyp. The quantiles are then found using the uniroot function.

pghyp and qghyp may generally be expected to be accurate to 5 decimal places.

The generalized hyperbolic distribution is discussed in Bibby and Sörenson (2003). It can be represented as a particular mixture of the normal distribution where the mixing distribution is the generalized inverse Gaussian. rghyp uses this representation to generate observations from the generalized hyperbolic distribution. Generalized inverse Gaussian observations are obtained via the algorithm of Dagpunar (1989) which is implemented in rgig.

References

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.

See Also

dhyperb for the hyperbolic distribution, dgig for the generalized inverse Gaussian distribution safeIntegrate, integrate for its shortfalls, splinefun, uniroot and ghypChangePars for changing parameters to the \((\alpha,\beta)\) parameterisation

Examples

Run this code
Theta <- c(1/2,3,1,1,0)
ghypRange <- ghypCalcRange(Theta, tol = 10^(-3))
par(mfrow = c(1,2))
curve(dghyp(x, Theta), from = ghypRange[1], to = ghypRange[2],
      n = 1000)
title("Density of the\n Generalized Hyperbolic Distribution")
curve(pghyp(x, Theta), from = ghypRange[1], to = ghypRange[2],
      n = 1000)
title("Distribution Function of the\n Generalized Hyperbolic Distribution")
dataVector <- rghyp(500, Theta)
curve(dghyp(x, Theta), range(dataVector)[1], range(dataVector)[2],
      n = 500)
hist(dataVector, freq = FALSE, add =TRUE)
title("Density and Histogram of the\n Generalized Hyperbolic Distribution")
logHist(dataVector, main =
   "Log-Density and Log-Histogramof the\n Generalized Hyperbolic Distribution")
curve(log(dghyp(x, Theta)), add = TRUE,
      range(dataVector)[1], range(dataVector)[2], n = 500)
par(mfrow = c(2,1))
curve(dghyp(x, Theta), from = ghypRange[1], to = ghypRange[2],
      n = 1000)
title("Density of the\n Generalized Hyperbolic Distribution")
curve(ddghyp(x, Theta), from = ghypRange[1], to = ghypRange[2],
      n = 1000)
title("Derivative of the Density of the\n Generalized Hyperbolic Distribution")
par(mfrow = c(1,1))
ghypRange <- ghypCalcRange(Theta, tol = 10^(-6))
curve(dghyp(x, Theta), from = ghypRange[1], to = ghypRange[2],
      n = 1000)
bks <- ghypBreaks(Theta)
abline(v = bks)

Run the code above in your browser using DataLab