Density, distribution function, quantile function and
random generation for the normal inverse-Gaussian distribution
with parameters p, a and b.
Usage
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
Examples
rnig(100, delta = 0, mu = 5, sigma = 1, nu = 1)
#> [1] 2.3439492 5.3833412 9.5358570 1.5939498 7.5353244 3.3921565
#> [7] 9.5890804 2.3115156 8.4849683 2.9107543 2.4402607 5.1390183
#> [13] 5.4532150 0.2400448 3.5988584 1.6467667 2.0676741 10.6484750
#> [19] 4.7586574 10.9724231 2.7365488 6.5160080 7.3347267 1.0473361
#> [25] 5.3979517 11.2315568 3.1328061 2.6453037 6.5727402 8.0726404
#> [31] 2.4203687 6.7129272 2.3465386 7.2918796 10.0474106 11.3005474
#> [37] 9.2461488 4.9342594 4.4990256 1.5037453 5.0211084 1.3028068
#> [43] 4.2153149 4.3899663 2.8442963 15.8191502 0.7444296 2.6071202
#> [49] 1.9393608 19.5869510 4.5235286 1.8926637 6.2644193 1.2679817
#> [55] 1.9303224 0.8644319 20.4249416 2.1501575 2.4153856 3.3724731
#> [61] 27.6009335 0.7867953 1.9969408 2.7307344 8.5065175 12.7440565
#> [67] 1.2242737 8.7049645 0.4186898 3.4774744 3.1307495 3.1883058
#> [73] 2.8348469 30.7586164 10.1407613 1.6493127 3.3852623 1.7681642
#> [79] 1.3541990 13.8061481 2.6952830 4.2482289 1.9046157 2.9241363
#> [85] 3.5290124 9.6417257 1.1963705 5.3684063 1.6974988 2.4390426
#> [91] 5.5531393 2.6304571 8.6348834 2.4474733 13.9593300 2.1011882
#> [97] 4.0109486 5.4702417 1.2235123 17.2361372
#> attr(,"V")
#> [1] 0.3028556 1.5276289 1.7015412 0.4492137 1.3032013 0.5638273 1.7456704
#> [8] 0.5411411 1.7190328 0.9806023 0.5652513 1.0074245 1.1024468 0.3255444
#> [15] 0.8340355 0.4464058 0.3784074 2.0316728 1.1525067 2.1097376 0.5402832
#> [22] 1.2057442 1.3138685 0.2400882 0.6672740 2.3756937 0.4476307 0.5625460
#> [29] 1.1853946 1.6311998 0.5919717 1.4709429 0.4466159 1.4310742 2.2482388
#> [36] 2.3322064 1.5536148 0.9502085 0.7231304 0.3542948 1.1566467 0.2574735
#> [43] 0.9298234 0.7610061 0.3573390 2.9460183 0.1230366 0.3565920 0.5119562
#> [50] 3.0644198 0.8964038 0.4197740 0.7784465 0.2022843 0.4599517 0.1934473
#> [57] 4.7220618 0.3815981 0.3724952 0.5038968 4.9928108 0.2678147 0.3605015
#> [64] 0.5753383 1.5198993 2.1733455 0.2714406 1.7436468 0.1923966 0.8969117
#> [71] 0.8144088 0.8671337 0.5334878 5.8509027 1.9956989 0.1966973 0.7783465
#> [78] 0.5236567 0.2652782 2.3858009 0.6079231 0.7228020 0.3555309 0.8258578
#> [85] 0.4756145 1.9637217 0.5462829 0.7785023 0.3383297 0.3255486 1.0555604
#> [92] 0.4706720 1.9636939 0.4345484 3.3259793 0.4873402 0.6568218 1.2081076
#> [99] 0.3517949 3.0761243
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))
