Inverse Gamma distribution
invgamma.RdDensity, distribution function, and random generation for the inverse Gamma distribution.
Usage
dinvgamma(x, shape, rate, scale = 1/rate, log = FALSE)
pinvgamma(q, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE)
qinvgamma(p, shape, rate, scale = 1/rate, lower.tail = TRUE, log.p = FALSE)
rinvgamma(n, shape, rate, scale = 1/rate)Arguments
- x, q
vector of quantiles, must be positive.
- shape, rate, scale
positive parameters of corresponding gamma distribution
- log, log.p
logical; if
TRUE, probabilities/ densities \(p\) are returned as \(\log(p)\).- lower.tail
logical; if
TRUE, probabilities are \(P[X \le x]\), otherwise, \(P[X > x]\).- p
vector of probabilities
- n
number of random values to return
Value
dinvgamma gives the density, pinvgamma gives the distribution function, qinvgamma gives the quantile function, and rinvgamma generates random deviates.
Details
This implementation of dinvgamma, pinvgamma, and qinvgamma allows for automatic differentiation with RTMB.
If \(X \sim \Gamma(\alpha, \beta)\), then \(1/X \sim \text{InvGamma}(\alpha, \beta)\).
$$f(x;\,\alpha,s) = \frac{s^\alpha}{\Gamma(\alpha)}\, x^{-(\alpha+1)}\exp\!\left(-\frac{s}{x}\right), \quad x > 0,$$ where \(s = \text{scale} = 1/\text{rate}\).