Learn R Programming

fBasics (version 200.10058)

HyperbolicDistribution: Generalized Hyperbolic Distribution

Description

A collection and description of functions to compute density, distribution function, quantile function and to generate random variates for two special cases of the generalized hyperbolic distribution: the hperbolic distribution and the normal inverse Gaussian distribution. The functions are: ll{ [dpqr]hyp The hyperbolic distribution, [dpqr]nig The normal inverse Gaussian distribution.}

Usage

dhyp(x, alpha , beta , delta , mu = 0)
phyp(q, alpha , beta , delta , mu = 0, ...)
qhyp(p, alpha , beta , delta , mu = 0)
rhyp(n, alpha , beta , delta , mu = 0)

dnig(x, alpha, beta, delta, mu = 0)
pnig(q, alpha, beta, delta, mu = 0)
qnig(p, alpha, beta, delta, mu = 0)
rnig(n, alpha, beta, delta, mu = 0)

Arguments

alpha, beta, delta, mu
shape parameter alpha; skewness parameter beta, abs(beta) is in the range (0,alpha); scale parameter delta, delta must be zero or positive; and
n
number of observations.
p
a numeric vector of probabilities.
x, q
a numeric vector of quantiles.
...
arguments to be passed to the function integrate.

Value

  • All values are numeric vectors: d* returns the density, p* returns the distribution function, q* returns the quantile function, and r* generates random deviates.

Details

Hyperbolic Distibution: The generator rhyperb is based on the HYP algorithm given by Atkinson (1982). Normal Inverse Gaussian Distribution: The random deviates are calculated with the method described by Raible (2000).

References

Atkinson, A.C. (1982); The simulation of generalized inverse Gaussian and hyperbolic random variables, SIAM J. Sci. Stat. Comput. 3, 502--515. Barndorff-Nielsen O. (1977); Exponentially decreasing distributions for the logarithm of particle size, Proc. Roy. Soc. Lond., A353, 401--419. Barndorff-Nielsen O., Blaesild, 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. Raible S. (2000); Levy Processes in Finance: Theory, Numerics and Empirical Facts, PhD Thesis, University of Freiburg, Germany, 161 pages.

See Also

dstable, dsymstb.

Examples

Run this code
## hyp -
   xmpBasics("Start: Hyperbolic Distribution > ")
   par(mfcol = c(3, 2), cex = 0.5)
   set.seed(1953)
   r = rhyp(1000, alpha = 1, beta = 0.3, delta = 1)
   plot(r, type = "l", col = "steelblue4",
     main = "hyp: alpha =1 beta=0.3 delta=1")
   # Plot empirical density and compare with true density:
   hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue4") 
   x = seq(-5, 7, 0.2)
   lines(x, dhyp(x, alpha = 1, beta = 0.3, delta = 1))
   # Plot df and compare with true df:
   plot(sort(r), (1:1000/1000), main = "Probability", col = "steelblue4")
   lines(x, phyp(x, alpha = 1, beta = 0.3, delta = 1))
   # Compute quantiles:
   qhyp(phyp(seq(-5, 7, 1), alpha = 1, beta = 0.3, delta = 1), 
     alpha = 1, beta = 0.3, delta = 1) 
 
     
## nig -
   xmpBasics("Next: Normal Inverse Gaussian Distribution > ")
   set.seed(1953)
   r = rnig(5000, alpha = 1, beta = 0.3, delta = 1)
   plot(r, type = "l", col = "steelblue4",
     main = "nig: alpha=1 beta=0.3 delta=1")
   # Plot empirical density and compare with true density:
   hist(r, n = 25, probability = TRUE, border = "white", col = "steelblue4")
   x = seq(-5, 5, 0.1)
   lines(x, dnig(x, alpha = 1, beta = 0.3, delta = 1))
   # Plot df and compare with true df:
   plot(sort(r), (1:5000/5000), main = "Probability", col = "steelblue4")
   lines(x, pnig(x, alpha = 1, beta = 0.3, delta = 1))
   # Compute Quantiles:
   qnig(pnig(seq(-5, 7, 1), alpha = 1, beta = 0.3, delta = 1), 
     alpha = 1, beta = 0.3, delta = 1)

Run the code above in your browser using DataLab