Density, distribution function, quantile function and random generation for the inverse gamma distribution.
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)
Arguments
- x, q
vector of quantiles.
- shape, rate, scale
shape
,rate
, andscale
parameters of corresponding gamma distribution. In particular,rate
andscale
are not the rate and scale of the inverse gamma distribution, but of the gamma distribution.- log, log.p
logical; if
TRUE
, probabilities p are given as log(p).- lower.tail
logical; if
TRUE
(default), probabilities are \(P[X \leq x]\); ifFALSE
\(P[X > x]\).- p
vector of probabilities.
- n
number of observations. If length(n) > 1, the length is taken to be the number required.
Details
The inverse gamma distribution with parameters shape and rate has density $$f(x) = \frac{rate^{shape}}{\Gamma(shape)} x^{-1-shape} e^{-rate/x}$$ it is the inverse of the standard gamma parameterization in R. If \(X \sim InvGamma(shape, rate)\), $$E[X] = \frac{rate}{shape-1}$$ when \(shape > 1\) and $$Var(X) = \frac{rate^2}{(shape - 1)^2(shape - 2)}$$ for \(shape > 2\).
The functions (d/p/q/r)invgamma()
simply wrap those of the standard
(d/p/q/r)gamma()
R implementation, so look at, say, stats::dgamma()
for
details.
See also
stats::dgamma()
; these functions just wrap the (d/p/q/r)gamma()
functions.