Learn R Programming

actuar (version 0.9-4)

InverseGamma: The Inverse Gamma Distribution

Description

Density function, distribution function, quantile function, random generation, raw moments, and limited moments for the Inverse Gamma distribution with parameters shape and scale.

Usage

dinvgamma(x, shape, rate = 1, scale = 1/rate, log = FALSE)
pinvgamma(q, shape, rate = 1, scale = 1/rate,
          lower.tail = TRUE, log.p = FALSE)
qinvgamma(p, shape, rate = 1, scale = 1/rate,
          lower.tail = TRUE, log.p = FALSE)
rinvgamma(n, shape, rate = 1, scale = 1/rate)
minvgamma(order, shape, rate = 1, scale = 1/rate)
levinvgamma(limit, shape, rate = 1, scale = 1/rate,
            order = 1)
mgfinvgamma(x, shape, rate =1, scale = 1/rate, 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.
shape, scale
parameters. Must be strictly positive.
rate
an alternative way to specify the scale.
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.
limit
limit of the loss variable.

Value

  • dinvgamma gives the density, pinvgamma gives the distribution function, qinvgamma gives the quantile function, rinvgamma generates random deviates, minvgamma gives the $k$th raw moment, and levinvgamma gives the $k$th moment of the limited loss variable, mgfinvgamma gives the moment generating function in x.

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

Details

The Inverse Gamma distribution with parameters shape $= \alpha$ and scale $= \theta$ has density: $$f(x) = \frac{u^\alpha e^{-u}}{x \Gamma(\alpha)}, \quad u = \theta/x$$ for $x > 0$, $\alpha > 0$ and $\theta > 0$. (Here $\Gamma(\alpha)$ is the function implemented by R's gamma() and defined in its help.)

The special case shape == 1 is an Inverse Exponential distribution.

The $k$th raw moment of the random variable $X$ is $E[X^k]$ and the $k$th limited moment at some limit $d$ is $E[\min(X, d)^k]$.

The moment generating function is given by $E[e^{xX}]$.

References

Klugman, S. A., Panjer, H. H. and Willmot, G. E. (2004), Loss Models, From Data to Decisions, Second Edition, Wiley.

Examples

Run this code
exp(dinvgamma(2, 3, 4, log = TRUE))
p <- (1:10)/10
pinvgamma(qinvgamma(p, 2, 3), 2, 3)
minvgamma(-1, 2, 2) ^ 2
levinvgamma(10, 2, 2, order = 1)
mgfinvgamma(1,3,2)

Run the code above in your browser using DataLab