InvChisquare | R Documentation |
Density, distribution function, quantile function, and
random generation for the (scaled) inverse chi-square
distribution with df
degrees of freedom and
optional parameter scale
. The parameterization is
consistent with Gelman et al. (2013). By default, the
scale
is set to return results for the inverse
chi-square distribution. If scale
is changed, then
the results are returned for the scaled inverse
chi-squared distribution.
rinvchisq(n, df, scale = 1/df)
dinvchisq(x, df, scale = 1/df, log = FALSE)
pinvchisq(q, df, scale = 1/df, lower.tail = TRUE, log.p = FALSE)
qinvchisq(p, df, scale = 1/df, lower.tail = TRUE, log.p = FALSE)
n |
number of observations. If |
df |
degrees of freedom (non-negative, but can be non-integer). |
scale |
a scale parameter. |
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/df
.
The scaled inverse chi-square distribution with
parameters df = n
and scale = s^2
has
density
f(x)= (2^{-n/2}/Gamma(n/2)s^n x^(-n/2 - 1) e^(-n
s^2/(2x))
for x \ge 0
, n > 0
and s > 0
. (Here
Gamma(n/2)
is the function implemented by R's
gamma()
and defined in its help. Note that n
= 0
corresponds to the trivial distribution with all
mass at point 0.)
The mean and variance are E(X) = n/(n - 2) s^2
for
n > 2
and Var(X) = 2n^2/(n-2)^2/(n-4) s^4
for
n>4
.
The cumulative hazard H(t) = - log(1 - F(t))
is
-pinvchisq(t, ..., lower = FALSE, log = TRUE)
dinvchisq
gives the density,
pinvchisq
gives the distribution function,
qinvchisq
gives the quantile function, and
rinvchisq
generates random deviates.
Invalid arguments will result in return value NaN
,
with a warning.
The length of the result is determined by n
for
rinvchisq
, 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.
Chisquare
x = 1:10
## InvChisquare(df = n) is a special case of
## InvGamma(shape = n/2, scale = 1/2)
n = 3
all.equal(dinvchisq(x, df = n),
dinvgamma(x, shape = n/2, scale = 1/2))
all.equal(pinvchisq(x, df = n),
pinvgamma(x, shape = n/2, scale = 1/2))
## InvChisquare(df = n, scale = s^2) is a special case of
## InvGamma(shape = n/2, scale = n/2 * s^2)
s = 1.7
all.equal(dinvchisq(x, df = n, scale = s^2),
dinvgamma(x, shape = n/2, scale = n/2 * s^2))
all.equal(pinvchisq(x, df = n, scale = s^2),
pinvgamma(x, shape = n/2, scale = n/2 * s^2))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.