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]  1.44721764  7.35662356  1.75698827  2.91029631  0.43385519  1.77584707
#>   [7] 18.62771527  1.93639736  2.91950048  3.48823154  2.36685577  4.86137237
#>  [13]  0.90069720  1.38644905 -0.05438779  1.66036122  6.41396857  0.98743391
#>  [19]  4.74123148  2.73413517  3.56152442  2.70084595  2.99429753 28.02351347
#>  [25] 13.79371241  8.06142658  3.49048724  6.62600325  5.18006159  1.62542504
#>  [31]  3.02178801  7.08286899  1.79761163 21.29429951  6.21314999  1.38220001
#>  [37]  1.76741385  2.29421644  4.92821094  3.72937019  5.95329926  9.95121203
#>  [43] 10.02588752  0.69619766  6.32108396  2.31654647 19.83555256  2.57483458
#>  [49]  7.65133184  0.96339066 13.17675075  1.71665227  3.62556437 14.47199544
#>  [55]  2.23321188  2.49229364  1.43740366  1.45440501  8.27264109  4.21823810
#>  [61] 10.98186050 10.74820260  0.19349517  2.17441561  3.91886161  4.12981998
#>  [67]  1.47504712  1.11056072  2.88591593  7.03321355  1.32381971  3.06186391
#>  [73]  2.34513816  2.75273515  1.81149050  2.40353857  3.42287413  1.43029270
#>  [79]  7.02744816  5.60949313  1.71420458  2.86497398 12.27183232  4.07790885
#>  [85]  1.20525353  4.55725159  3.82362725  3.42307344  6.46939819 18.77815013
#>  [91]  9.99777521  0.49057824  1.70353193  0.85305339  6.77757322  2.79328461
#>  [97]  3.60143246  1.58060075  2.32198207  2.04085197
#> attr(,"V")
#>   [1] 0.2168469 1.1482281 0.6442572 0.4735765 0.1660719 0.2635001 3.4423677
#>   [8] 0.3142418 0.6717376 0.7118284 0.8427569 1.0789312 0.1717255 0.2832732
#>  [15] 0.2142993 0.4124226 1.4971564 0.1736882 0.8836026 0.7037138 0.6647348
#>  [22] 0.5331889 0.5340022 5.2973323 2.8645115 1.0862223 0.7718445 1.0510238
#>  [29] 1.0824617 0.2641207 0.6145910 1.5936064 0.4288273 4.1893612 1.2174484
#>  [36] 0.3737931 0.3826877 0.3238720 0.9490217 0.5867317 1.2929499 2.2004822
#>  [43] 1.9965788 0.1771043 1.1221571 0.2770587 3.7222786 0.4647289 1.2247843
#>  [50] 0.2853094 1.9541980 0.3382309 0.7813801 2.1127853 0.3766270 0.5815400
#>  [57] 0.3136621 0.4977103 1.5567043 0.6928346 1.8679132 1.8303306 0.1092448
#>  [64] 0.3942186 0.8185922 0.7026247 0.1853585 0.2474985 0.5787121 1.7327275
#>  [71] 0.3991258 0.7988214 0.6708670 0.5175688 0.2947765 0.4650417 0.4771664
#>  [78] 0.3544105 1.7130042 1.1105193 0.2270295 0.6438680 2.2314935 0.7780190
#>  [85] 0.4111090 0.6436659 0.7871228 1.1252339 0.9652056 3.7517338 1.6358305
#>  [92] 0.0827018 0.2967051 0.2560967 1.2618818 0.8246048 0.8066153 0.2300828
#>  [99] 0.5407021 0.5409714
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))