InverseGaussian: The Inverse Gaussian Distribution

InverseGaussianR Documentation

The Inverse Gaussian Distribution

Description

Density function, distribution function, quantile function, random generation, raw moments, limited moments and moment generating function for the Inverse Gaussian distribution with parameters mean and shape.

Usage

dinvgauss(x, mean, shape = 1, dispersion = 1/shape,
          log = FALSE)
pinvgauss(q, mean, shape = 1, dispersion = 1/shape,
          lower.tail = TRUE, log.p = FALSE)
qinvgauss(p, mean, shape = 1, dispersion = 1/shape,
          lower.tail = TRUE, log.p = FALSE,
          tol = 1e-14, maxit = 100, echo = FALSE, trace = echo)
rinvgauss(n, mean, shape = 1, dispersion = 1/shape)
minvgauss(order, mean, shape = 1, dispersion = 1/shape)
levinvgauss(limit, mean, shape = 1, dispersion = 1/shape, order = 1)
mgfinvgauss(t, mean, shape = 1, dispersion = 1/shape, log = FALSE)

Arguments

x, q

vector of quantiles.

p

vector of probabilities.

n

number of observations. If length(n) > 1, the length is taken to be the number required.

mean, shape

parameters. Must be strictly positive. Infinite values are supported.

dispersion

an alternative way to specify the shape.

log, log.p

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

lower.tail

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

order

order of the moment. Only order = 1 is supported by levinvgauss.

limit

limit of the loss variable.

tol

small positive value. Tolerance to assess convergence in the Newton computation of quantiles.

maxit

positive integer; maximum number of recursions in the Newton computation of quantiles.

echo, trace

logical; echo the recursions to screen in the Newton computation of quantiles.

t

numeric vector.

Details

The inverse Gaussian distribution with parameters mean = \mu and dispersion = \phi has density:

f(x) = \left( \frac{1}{2 \pi \phi x^3} \right)^{1/2} \exp\left( -\frac{(x - \mu)^2}{2 \mu^2 \phi x} \right),

for x \ge 0, \mu > 0 and \phi > 0.

The limiting case \mu = \infty is an inverse chi-squared distribution (or inverse gamma with shape = 1/2 and rate = 2phi). This distribution has no finite strictly positive, integer moments.

The limiting case \phi = 0 is an infinite spike in x = 0.

If the random variable X is IG(\mu, \phi), then X/\mu is IG(1, \phi \mu).

The kth raw moment of the random variable X is E[X^k], k = 1, 2, \dots, the limited expected value at some limit d is E[\min(X, d)] and the moment generating function is E[e^{tX}].

The moment generating function of the inverse guassian is defined for t <= 1/(2 * mean^2 * phi).

Value

dinvgauss gives the density, pinvgauss gives the distribution function, qinvgauss gives the quantile function, rinvgauss generates random deviates, minvgauss gives the kth raw moment, levinvgauss gives the limited expected value, and mgfinvgauss gives the moment generating function in t.

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

Note

Functions dinvgauss, pinvgauss and qinvgauss are C implementations of functions of the same name in package statmod; see Giner and Smyth (2016).

Devroye (1986, chapter 4) provides a nice presentation of the algorithm to generate random variates from an inverse Gaussian distribution.

The "distributions" package vignette provides the interrelations between the continuous size distributions in actuar and the complete formulas underlying the above functions.

Author(s)

Vincent Goulet vincent.goulet@act.ulaval.ca

References

Giner, G. and Smyth, G. K. (2016), “statmod: Probability Calculations for the Inverse Gaussian Distribution”, R Journal, vol. 8, no 1, p. 339-351. https://journal.r-project.org/archive/2016-1/giner-smyth.pdf

Chhikara, R. S. and Folk, T. L. (1989), The Inverse Gaussian Distribution: Theory, Methodology and Applications, Decker.

Devroye, L. (1986), Non-Uniform Random Variate Generation, Springer-Verlag. http://luc.devroye.org/rnbookindex.html

See Also

dinvgamma for the inverse gamma distribution.

Examples

dinvgauss(c(-1, 0, 1, 2, Inf), mean = 1.5, dis = 0.7)
dinvgauss(c(-1, 0, 1, 2, Inf), mean = Inf, dis = 0.7)
dinvgauss(c(-1, 0, 1, 2, Inf), mean = 1.5, dis = Inf) # spike at zero

## Typical graphical representations of the inverse Gaussian
## distribution. First fixed mean and varying shape; second
## varying mean and fixed shape.
col = c("red", "blue", "green", "cyan", "yellow", "black")
par = c(0.125, 0.5, 1, 2, 8, 32)
curve(dinvgauss(x, 1, par[1]), from = 0, to = 2, col = col[1])
for (i in 2:6)
    curve(dinvgauss(x, 1, par[i]), add = TRUE, col = col[i])

curve(dinvgauss(x, par[1], 1), from = 0, to = 2, col = col[1])
for (i in 2:6)
    curve(dinvgauss(x, par[i], 1), add = TRUE, col = col[i])

pinvgauss(qinvgauss((1:10)/10, 1.5, shape = 2), 1.5, 2)

minvgauss(1:4, 1.5, 2)

levinvgauss(c(0, 0.5, 1, 1.2, 10, Inf), 1.5, 2)

actuar documentation built on Nov. 8, 2023, 9:06 a.m.