InvGammaDist | R Documentation |
Density, distribution function, quantile function, and random generation for
the inverse gamma distribution with parameters shape
and scale
. Note that
the parameterization is consistent with Gelman et al. (2013) (see References) and
that scale
precedes rate
in the argument list, which is the
reverse of the GammaDist
functions.
rinvgamma(n, shape, scale = 1, rate = 1/scale)
dinvgamma(x, shape, scale = 1, rate = 1/scale, log = FALSE)
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
)
n |
number of observations. If |
shape, scale |
shape and scale parameters. Must be positive,
|
rate |
an alternative way to specify the scale. |
x, q |
vector of quantiles. |
log, log.p |
logical; if |
lower.tail |
logical; if TRUE (default), probabilities are
|
p |
vector of probabilities. |
If scale
is omitted, it assumes the default value of 1.
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 \ge 0
, a > 0
and s > 0
. (Here Gamma(a)
is the function implemented by R's
gamma()
and defined in its help. Note that a = 0
corresponds to the trivial distribution with all mass at point 0.)
The mean and variance are E(X) = s/(a - 1)
for a>1
and Var(X) = s^2/(a-1)^2/(a-2)
for a>2
.
The cumulative hazard H(t) = - log(1 - F(t))
is
-pinvgamma(t, ..., lower = FALSE, log = TRUE)
dinvgamma
gives the density, pinvgamma
gives the distribution function,
qinvgamma
gives the quantile function, and rinvgamma
generates random deviates.
Invalid arguments will result in return value NaN
, with a warning.
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.
The numerical arguments other than n
are recycled to the length
of the result. Only the first elements of the logical arguments are used.
Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2013). Bayesian data analysis, 3rd edition. CRC press.
GammaDist
-log(dinvgamma(1:4, shape = 1))
p <- (1:9)/10
pinvgamma(qinvgamma(p, shape = 2), shape = 2)
1 - 1/exp(qinvgamma(p, shape = 1))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.