Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples
Density, distribution function, quantile function and random numbers generator for the Inverse Gamma Distribution.
1 2 3 4 
x, q, p, n 
Same as 
scale, shape 
Scale and shape parameters, same as

rate 
Same as 
log, log.p, lower.tail 
Same as 
The Inverse Gamma density with parameters scale = b and shape = s is given by
f(y) = (b^s / Γ(s)) * y^(s1) * e^(b/y),
for y > 0, b > 0, and s > 0.
Here, gamma() is the gamma function as in
gamma
The relation between the Gamma Distribution and the Inverse Gamma Distribution is as follows:
Let X be a random variable distributed as Gamma (b , s), then Y = 1/X is distributed as Inverse Gamma (1/b , s). It is worth noting that the math relation between the scale paramaters of both, the Inverse Gamma and Gamma distributions, is inverse.
Thus, algorithms of dinvgamma(), pinvgamma(), qinvgamma() and
rinvgamma() underlie on the algorithms
GammaDist
.
Let Y distributed as Inverse Gamma (b , s). Then the kth moment of Y exists for ∞ < k < s and is given by
E[Y^k] = (b^k) * (Γ(s  k)/Γ(s)).
The mean (if s > 1) and variance (if s >2) are
E[Y] = b/(s  1); Var[Y] = b^2 / [((s  1)^2) * (s  2)].
dinvgamma()
returns the density, pinvgamma()
gives the
distribution function, qinvgamma()
gives the quantiles, and
rinvgamma()
generates random deviates.
The order of the arguments scale and shape does not match
GammaDist
.
Unlike the GammaDist
, small values
of shape (plus modest mu) or very large values of
mu (plus moderate shape > 2), generate Inverse Gamma
values so near to zero. Thus, rinvgamma
in
invgammaDist
may return either values
too close to zero or values represented as zero in computer arithmetic.
In addition, function dinvgamma
will return zero for
x = 0, which is the limit of the Inverse Gamma density when
'x' tends to zero.
V. Miranda and T. W. Yee.
Kleiber, C. and Kotz, S. (2003) Statistical Size Distributions in Economics and Actuarial Sciences. Wiley Series in Probability and Statistics. Hoboken, New Jersey, USA.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  # Example 1.______________________
n < 20
scale < exp(2)
shape < exp(1)
data.1 < runif(n, 0, 1)
data.q < qinvgamma(data.1, scale = scale, shape = shape, log.p = TRUE)
data.p < log(pinvgamma(data.q, scale = scale, shape = shape))
arg.max < max(abs(data.p  data.1)) # Should be zero
# Example 2.______________________
scale < exp(1.0)
shape < exp(1.2)
xx < seq(0, 3.0, len = 201)
yy < dinvgamma(xx, scale = scale, shape = shape)
qtl < seq(0.1, 0.9, by = 0.1)
d.qtl < qinvgamma(qtl, scale = scale, shape = shape)
plot(xx, yy, type = "l", col = "orange",
main = "Orange is density, blue is cumulative distribution function",
sub = "Brown dashed lines represent the 10th, ... 90th percentiles",
las = 1, xlab = "x", ylab = "", ylim = c(0, 1))
abline(h = 0, col= "navy", lty = 2)
lines(xx, pinvgamma(xx, scale = scale, shape = shape), col = "blue")
lines(d.qtl, dinvgamma(d.qtl, scale = scale, shape = shape),
type ="h", col = "brown", lty = 3)

Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.