Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

Inverse-Gamma

The Inverse Gamma Distribution


Description

Density, distribution function, quantile function and random generation for the inverse gamma distribution with rate or scale (mean = scale / (shape - 1)) parameterizations.

Usage

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)

Arguments

x

vector of values.

shape

vector of shape values, must be positive.

scale

vector of scale values, must be positive.

rate

vector of rate values, must be positive.

log

logical; if TRUE, probability density is returned on the log scale.

n

number of observations.

q

vector of quantiles.

lower.tail

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

log.p

logical; if TRUE, probabilities p are given by user as log(p).

p

vector of probabilities.

Details

The inverse gamma distribution with parameters shape = a and scale = s has density

f(x)= (s^a / Gamma(a)) x^-(a+1) e^-(s/x)

for x ≥ 0, a > 0 and s > 0. (Here Gamma(a) is the function implemented by R's gamma() and defined in its help.

The mean and variance are E(X) = s/(a-1) and Var(X) = s^2 / ((a-1)^2 * (a-2)), with the mean defined only for a > 1 and the variance only for a > 2.

See Gelman et al., Appendix A or the BUGS manual for mathematical details.

Value

dinvgamma gives the density, pinvgamma gives the distribution function, qinvgamma gives the quantile function, and rinvgamma generates random deviates.

Author(s)

Christopher Paciorek

References

Gelman, A., Carlin, J.B., Stern, H.S., and Rubin, D.B. (2004) Bayesian Data Analysis, 2nd ed. Chapman and Hall/CRC.

See Also

Distributions for other standard distributions

Examples

x <- rinvgamma(50, shape = 1, scale = 3)
dinvgamma(x, shape = 1, scale = 3)

nimble

MCMC, Particle Filtering, and Programmable Hierarchical Modeling

v0.11.0
BSD_3_clause + file LICENSE | GPL (>= 2)
Authors
Perry de Valpine [aut], Christopher Paciorek [aut, cre], Daniel Turek [aut], Nick Michaud [aut], Cliff Anderson-Bergman [aut], Fritz Obermeyer [aut], Claudia Wehrhahn Cortes [aut] (Bayesian nonparametrics system), Abel Rodrìguez [aut] (Bayesian nonparametrics system), Duncan Temple Lang [aut] (packaging configuration), Sally Paganin [aut] (reversible jump MCMC), Jagadish Babu [ctb] (code for the compilation system for an early version of NIMBLE), Lauren Ponisio [ctb] (contributions to the cross-validation code), Peter Sujan [ctb] (multivariate t distribution code)
Initial release
2021-04-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.