Density, distribution function, quantile function and random generation for the normal inverse-Gaussian distribution with parameters p, a and b.

dnig(x, delta, mu, nu, sigma, h = NULL, log = FALSE)

rnig(n, delta, mu, nu, sigma, h = NULL, seed = 0)

pnig(q, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)

qnig(p, delta, mu, nu, sigma, h = NULL, lower.tail = TRUE, log.p = FALSE)

Arguments

x, q

vector of quantiles.

delta

A numeric value for the location parameter.

mu

A numeric value for the shift parameter.

nu

A numeric value for the shape parameter.

sigma

A numeric value for the scaling parameter.

h

A numeric value for the additional parameter, see details.

log, log.p

logical; if TRUE, probabilities/densities \(p\) are returned as \(log(p)\).

n,

number of observations.

seed

Seed for the random generation.

lower.tail

logical; if TRUE, probabilities are \(P[X\leq x]\), otherwise, \(P[X>x]\).

p

vector of probabilities.

Value

dnig gives the density, pnig gives the distribution function, qnig gives the quantile function, and rnig generates random deviates.

Invalid arguments will result in return value NaN, with a warning.

The length of the result is determined by n for rnig.

Details

The normal inverse-Gaussian distribution has density given by $$f(x; \delta, \mu, \sigma, \nu) = \frac{e^{\nu+\mu(x-\delta)/\sigma^2}\sqrt{\nu\mu^2/\sigma^2+\nu^2}}{\pi\sqrt{\nu\sigma^2+(x-\delta)^2}} K_1(\sqrt{(\nu\sigma^2+(x-\delta)^2)(\mu^2/\sigma^4+\nu/\sigma^2)}),$$ where \(K_p\) is modified Bessel function of the second kind of order \(p\), \(x>0\), \(\nu>0\) and \(\mu,\delta, \sigma\in\mathbb{R}\). See Barndorff-Nielsen (1977, 1978 and 1997) for further details.

The additional parameter h is used when $$V\sim IG(\nu,\nu h^{2})$$. By the infinite divisibility, $$\frac{1}{h} V \sim IG(\nu h, \nu h)$$. Then $$\delta+\mu V + \sigma \sqrt{V} Z$$ has the distribution of $$NIG(\delta=-\mu h,\mu= \mu h, \sigma=\sigma \sqrt{h}, \nu=\nu h).$$

References

Barndorff-Nielsen, O. (1977) Exponentially decreasing distributions for the logarithm of particle size. Proceedings of the Royal Society of London.

Series A, Mathematical and Physical Sciences. The Royal Society. 353, 401–409. doi:10.1098/rspa.1977.0041

Barndorff-Nielsen, O. (1978) Hyperbolic Distributions and Distributions on Hyperbolae, Scandinavian Journal of Statistics. 5, 151–157.

Barndorff-Nielsen, O. (1997) Normal Inverse Gaussian Distributions and Stochastic Volatility Modelling, Scandinavian Journal of Statistics. 24, 1-13. doi:10.1111/1467-9469.00045

See also

Examples

rnig(100, delta = 0, mu = 5, sigma = 1, nu = 1)
#>   [1]  5.1276215  1.8406323  6.0817360  2.9719201  4.3748009 12.5532995
#>   [7] 12.2363205  9.9045024  1.6485338  4.5439543  1.2882588  2.2776308
#>  [13]  0.7222549  2.4808883 18.4222818 11.9711087  1.7270974  2.1116931
#>  [19]  1.8994245  1.7119225  2.0644486  4.2771172  2.4495305  2.0310035
#>  [25]  2.5707792  3.6950465  2.8229247  2.1459641  4.7128527  3.4585366
#>  [31]  1.3756348 36.9615426 14.3933791  8.4634548  8.3032632  2.4459735
#>  [37] 23.2364665  1.8587594  3.2949523  1.6192898  1.2832631 11.7585964
#>  [43]  8.7183803  5.2023338  6.9106093  3.4982695  1.0606901  5.7354858
#>  [49]  2.1643738  9.3034015  1.0593692  1.7071888  8.8854429  8.2775389
#>  [55] 17.3014629  2.3695782  0.3138479  2.1517816  3.3552073  3.9270798
#>  [61] 17.0949939  0.7806187  2.7829281 19.6674443  3.7094782  4.1226776
#>  [67]  8.0082259 11.5762891  4.5043622  0.3946934  2.3437853  4.1374464
#>  [73]  7.7685311  2.8626140 26.6898149  1.7512999  2.6615947 12.4441493
#>  [79]  4.0869612  2.9367137  3.1167161  4.1891038  3.3427499  1.6886385
#>  [85] 13.3687279  2.4679511  2.5921591 13.2780933  4.9113175  2.2592181
#>  [91]  3.4070040  2.0652749 10.5429449  2.9170650  2.6601201  3.2867544
#>  [97]  2.1132717  2.3206708  1.9487111 14.1251465
#> attr(,"V")
#>   [1] 0.7622714 0.6658542 1.0544710 0.7645325 0.7231034 2.2801910 2.2517513
#>   [8] 2.1375909 0.3395011 1.3817764 0.3153099 0.4420271 0.1487873 0.9769647
#>  [15] 3.9325723 2.6810822 0.3134490 0.3799489 0.5139617 0.3099039 0.4067927
#>  [22] 0.7771800 0.4049253 0.4480306 0.2578486 0.8147797 0.3962389 0.4594547
#>  [29] 0.8342238 0.7026493 0.3591724 7.6857120 2.8216392 1.6632577 1.8789198
#>  [36] 0.5233477 4.1633692 0.3495276 0.5105402 0.3792580 0.3391958 2.3424056
#>  [43] 1.8666030 0.9123724 1.0240485 0.6012544 0.1808026 0.8871138 0.5629973
#>  [50] 1.3042188 0.2078759 0.3807134 1.1903964 1.5150792 3.6689749 0.5072087
#>  [57] 0.1908442 0.3819035 0.5381286 0.5993589 3.0095510 0.2662578 0.5103190
#>  [64] 4.0105606 0.6255204 0.6234396 1.6675401 2.3183180 1.1686733 0.1654450
#>  [71] 0.6349903 1.0840648 1.4976088 0.4858382 5.2851499 0.2120089 0.6229381
#>  [78] 2.8881254 0.8076877 0.4282782 0.6970873 0.7119341 0.6346249 0.5309984
#>  [85] 2.1808366 0.5116479 0.9159745 2.1635365 0.9802719 0.2968901 0.6385698
#>  [92] 0.3642986 2.3685665 0.5231262 0.7927913 0.7400404 0.3210260 0.5404199
#>  [99] 0.5199356 2.4910757
pnig(0.4, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 0.01597497
qnig(0.8, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 7.390234
plot(function(x){dnig(x, delta = 0, mu = 5, sigma = 1, nu = 1)}, main =
"Normal inverse-Gaussian density", ylab = "Probability density",
xlim = c(0,10))