These functions provide the density function, distribution function, quantile function, and random number generation for the Inverse-Gamma (IG) Distribution
dinvgamma(x, shape = 2.5, scale = 1, log = FALSE)pinvgamma(q, shape = 2.5, scale = 1, lower.tail = TRUE, log.p = FALSE)
qinvgamma(p, shape = 2.5, scale = 1, lower.tail = TRUE, log.p = FALSE)
rinvgamma(n, shape = 2.5, scale = 1)
dinvgamma gives the density, pinvgamma gives the distribution function, qinvgamma gives the quantile function, and rinvgamma generates random deviates.
The length of the result is determined by n for rinvgamma, and is the maximum of the lengths of the numerical arguments for the other functions.
numeric value or a vector of values.
numeric value or vector of shape values for the distribution (the values have to be greater than 0).
single value or vector of values for the scale parameter of the distribution (the values have to be greater than 0).
logical; if TRUE, probabilities p are given as log(p).
quantile or a vector of quantiles.
logical; if TRUE, probabilities p are \(P[X\leq x]\) otherwise, \(P[X>x]\).
logical; if TRUE, probabilities p are given as log(p).
probability or a vector of probabilities.
the number of random numbers to generate.
dinvgamma computes the density (PDF) of the Inverse-Gamma
Distribution.
pinvgamma computes the CDF of the Inverse-Gamma Distribution.
qinvgamma computes the quantile function of the Inverse-Gamma
Distribution.
rinvgamma generates random numbers from the Inverse-Gamma
Distribution.
The compound Probability Mass Function (PMF) for the Inverse-Gamma distribution: $$f(x | \alpha, \beta) = \frac{\beta^\alpha}{\Gamma(\alpha)} \left(\frac{1}{x}\right)^{\alpha+1} e^{-\frac{\beta}{x}}$$
Where \(\alpha\) is the shape parameter and \(\beta\) is a scale parameter with the restrictions that \(\alpha > 0\) and \(\eta > 0\), and \(x > 0\).
The CDF of the Inverse-Gamma distribution is: $$F(x | \alpha, \beta) = \frac{\alpha. \Gamma \left(\frac{\beta}{x}\right)}{\Gamma(\alpha)} = Q\left(\alpha, \frac{\beta}{x} \right)$$
Where the numerator is the incomplete gamma function and \(Q(\cdot)\) is the regularized gamma function.
The mean of the distribution is (provided \(\alpha>1\)): $$\mu=\frac{\beta}{\alpha-1}$$
The variance of the distribution is (for \(\alpha>2\)): $$\sigma^2=\frac{\beta^2}{(\alpha-1)^2(\alpha-2)}$$
dinvgamma(1, shape = 3, scale = 2)
pinvgamma(c(0.1, 0.5, 1, 3, 5, 10, 30), shape = 3, scale = 2)
qinvgamma(c(0.1, 0.3, 0.5, 0.9, 0.95), shape = 3, scale = 2)
rinvgamma(30, shape = 3, scale = 2)
Run the code above in your browser using DataLab