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] 10.13134093 11.54257853  6.98900376  2.89141624  1.81289452  5.64159885
#>   [7] 13.27547014  1.26737249  0.91485375  0.50097533 -0.09489649  1.46074368
#>  [13]  2.38664598  1.79546122  0.12425718  2.09892758  2.15870386  2.02732982
#>  [19]  3.90745536  1.85945346  7.54989886  7.20975787  5.62162176  3.56345837
#>  [25]  5.91099910  2.61731814  5.47350786 13.40369016  0.51352316  7.15334722
#>  [31]  3.56010414  0.88332494  4.85288844  4.61821631 13.38402815  1.81445400
#>  [37]  4.67223595  2.56412228  2.65519336  3.05116552  0.67325797  0.94154387
#>  [43]  2.86828104  5.13160362  1.13302171  7.96489004  1.97786198 33.34940541
#>  [49] 14.42447797  1.67319802  5.68030005  4.72149343 24.32149022  3.94944103
#>  [55]  2.14119082  1.16081447  2.57852909  1.66629524 15.97626727  1.06265975
#>  [61]  3.15975394  1.69363149  0.97238445  2.60892864  8.42674208  2.58195428
#>  [67] 12.96254145  8.81825294  3.15009586  1.16317146 12.55906822  0.88468653
#>  [73]  0.90460894  2.71446739  3.31011175  3.10306354 11.56474031  0.59844574
#>  [79]  2.45979849  1.76015204  2.86088386  0.60024844 18.76348930  3.67549062
#>  [85]  0.66419277  2.18024906 12.66059792 31.75127454  6.02923826 11.98787955
#>  [91]  1.26641795  6.06332379  2.84026588  6.07888495  4.69564943  0.54885143
#>  [97]  1.48581171  7.93009680  1.85067232  1.98218860
#> attr(,"V")
#>   [1] 1.8161719 1.8935978 1.9008408 0.4701892 0.5002062 0.9539038 2.4177739
#>   [8] 0.1958188 0.2349147 0.1056590 0.1209678 0.3531703 0.4635060 0.3658924
#>  [15] 0.2841358 0.5090540 0.5632192 0.3706982 0.7230159 0.5047622 1.4399656
#>  [22] 1.4305181 1.0340712 0.6085153 1.2521289 0.2640786 1.1861222 2.2771654
#>  [29] 0.1180436 1.2956434 0.7231210 0.2462566 1.0805933 0.8915818 2.6397258
#>  [36] 0.4723255 0.9812115 0.3687961 0.5043425 0.4680886 0.1719551 0.2606691
#>  [43] 0.5690656 1.1216096 0.1711283 1.2046166 0.3234056 6.4822540 2.4526106
#>  [50] 0.4511177 0.7220258 0.9358162 5.0067280 0.4351639 0.3598043 0.2909260
#>  [57] 0.5503871 0.5508497 3.0581429 0.1438198 0.4676103 0.2264198 0.3140964
#>  [64] 0.4770525 1.7360562 0.4209262 2.2135827 1.8327324 0.6316165 0.3866763
#>  [71] 2.8722531 0.2891032 0.3204113 0.5101523 0.5682717 0.6027770 1.8991648
#>  [78] 0.1665449 0.6866551 0.3456816 0.4155026 0.1548009 3.4745911 0.6994817
#>  [85] 0.2708793 0.2644171 2.5726110 7.4868099 0.8902020 2.3944632 0.1449955
#>  [92] 1.1550603 0.5103454 1.4168505 0.8617532 0.2587436 0.3543839 1.3756427
#>  [99] 0.4388811 0.5275854
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))