Density, distribution function, quantile function and random generation for the inverse gamma distribution with rate or scale (mean = scale / (shape - 1)) parameterizations.
dinvgamma(x, shape, scale = 1, rate = 1/scale, log = FALSE)rinvgamma(n = 1, shape, scale = 1, rate = 1/scale)
pinvgamma(
q,
shape,
scale = 1,
rate = 1/scale,
lower.tail = TRUE,
log.p = FALSE
)
qinvgamma(
p,
shape,
scale = 1,
rate = 1/scale,
lower.tail = TRUE,
log.p = FALSE
)
dinvgamma
gives the density, pinvgamma
gives the distribution
function, qinvgamma
gives the quantile function, and rinvgamma
generates random deviates.
vector of values.
vector of shape values, must be positive.
vector of scale values, must be positive.
vector of rate values, must be positive.
logical; if TRUE, probability density is returned on the log scale.
number of observations.
vector of quantiles.
logical; if TRUE (default) probabilities are \(P[X \le x]\); otherwise, \(P[X > x]\).
logical; if TRUE, probabilities p are given by user as log(p).
vector of probabilities.
Christopher Paciorek
The inverse gamma distribution with parameters shape
\(=\alpha\) and
scale
\(=\sigma\) has density
$$
f(x)= \frac{s^a}{\Gamma(\alpha)} {x}^{-(\alpha+1)} e^{-\sigma/x}%
$$
for \(x \ge 0\), \(\alpha > 0\) and \(\sigma > 0\).
(Here \(\Gamma(\alpha)\) is the function implemented by R's
gamma()
and defined in its help.
The mean and variance are \(E(X) = \frac{\sigma}{\alpha}-1\) and \(Var(X) = \frac{\sigma^2}{(\alpha-1)^2 (\alpha-2)}\), with the mean defined only for \(\alpha > 1\) and the variance only for \(\alpha > 2\).
See Gelman et al., Appendix A or the BUGS manual for mathematical details.
Gelman, A., Carlin, J.B., Stern, H.S., and Rubin, D.B. (2004) Bayesian Data Analysis, 2nd ed. Chapman and Hall/CRC.
Distributions for other standard distributions
x <- rinvgamma(50, shape = 1, scale = 3)
dinvgamma(x, shape = 1, scale = 3)
Run the code above in your browser using DataLab