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]  8.7453750  2.8308955  1.9724275  2.8110962  1.4594403  3.2671052
#>   [7]  3.2355462  2.9315198  2.5349153  2.3832719  1.5519017  5.6814750
#>  [13]  3.2790305  2.2722631  1.0213813  2.3654438  2.0877757  2.2165460
#>  [19]  7.5850430  3.6070234  4.1874932 19.6685252  2.0305431  8.2280059
#>  [25]  6.2074429  5.3174653  1.7533742  6.8143572 20.6072128  3.0763522
#>  [31]  0.8700679  4.1558217  0.8131672  1.7880555  2.9477745  0.3996503
#>  [37]  5.4088809  7.4033324  4.7681994  3.7241152  4.9681600  3.8509978
#>  [43]  2.2681666  6.6549210 18.5553461  2.8039807 12.1758530  5.0738720
#>  [49]  5.9370232  5.7516808  3.7399890  3.4188263  7.5149911  8.7126576
#>  [55]  3.8238557  2.6858357 18.6827554  1.0389499  5.8644832  4.0301653
#>  [61]  3.2736731 17.8481755  0.6808185  3.7540424  5.7806961  4.3423036
#>  [67] 23.3667689  9.5046257  2.5281619  7.4816523  9.9574762  2.2340712
#>  [73]  1.0845869  3.2416045 11.9018097  2.4101661  2.0566656 16.2621300
#>  [79]  2.5957437  8.4228372  4.2349747  0.7177702  1.0639074  1.0502710
#>  [85]  3.6102284  4.8287110  1.4865197  3.0762955  7.8585251 26.9624196
#>  [91]  1.7318547  7.8330814  1.2389699  3.9626429  1.3801046 11.3949497
#>  [97]  2.9691890  7.8221965  1.3701698  4.0366242
#> attr(,"V")
#>   [1] 1.5546904 0.3802481 0.6996824 0.4557928 0.4176456 0.5241340 0.5354287
#>   [8] 0.4946668 0.5892509 0.4884018 0.6296706 1.2511490 0.6395684 0.4620946
#>  [15] 0.5722368 0.5673284 0.5471436 0.4068840 1.4346386 0.8986993 0.7857785
#>  [22] 3.9147910 0.3533504 1.4829715 1.3131000 0.6549897 0.4040313 1.0843781
#>  [29] 4.2130802 0.5289925 0.1795447 0.9692267 0.2112800 0.3378741 0.5722899
#>  [36] 0.1393770 1.1320055 1.2188321 0.9176302 0.5858062 1.0874412 0.9050298
#>  [43] 0.4495531 1.4389133 3.4615636 0.3511235 2.2450301 0.9432037 0.9223135
#>  [50] 1.3519798 0.4288925 0.6765529 1.5830879 1.1627037 0.6712962 0.6231708
#>  [57] 3.8280145 0.3911449 1.0910021 0.6589538 0.4870183 3.1506960 0.2409283
#>  [64] 0.6967474 1.1982671 0.7417352 4.1542521 1.9725944 0.5070635 1.8315886
#>  [71] 2.3150928 0.6097040 0.3660005 0.6124470 2.1960648 0.4663453 0.2586346
#>  [78] 3.4661844 0.7182767 1.6706105 0.6508995 0.1811463 0.1541953 0.1914222
#>  [85] 0.9853197 0.6887402 0.3113913 1.0385706 1.2045365 5.3878148 0.2146235
#>  [92] 1.5009508 0.2107132 0.9578552 0.2355657 2.7660760 0.6726739 1.3556007
#>  [99] 0.3340069 0.9866747
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))