Learn R Programming

geoR (version 1.2-5)

InvChisquare: The (Scaled) Inverse Chi-Squared Distribution

Description

Density and random generation for the scaled inverse chi-squared ($\chi^2_{ScI}$) distribution with df degrees of freedom and optional non-centrality parameter scale.

Usage

dinvchisq(x, df, scale, log = FALSE)
rinvchisq(n, df, scale = 1/df)

Arguments

x
vector of quantiles.
n
number of observations. If length(n) > 1, the length is taken to be the number required.
df
degrees of freedom.
scale
scale parameter.
log
logical; if TRUE, densities d are given as log(d).

Value

  • dinvchisq gives the density and rinvchisq generates random deviates.

eqn

$\lambda = n/2$

Details

The inverse chi-squared distribution with df$= n$ degrees of freedom has density $$f(x) = \frac{1}{{2}^{n/2} \Gamma (n/2)} {(1/x)}^{n/2+1} {e}^{-1/(2x)}$$ for $x > 0$. The mean and variance are $\frac{1}{(n-2)}$ and $\frac{2}{(n-4)(n-2)^2}$.

The non-central chi-squared distribution with df$= n$ degrees of freedom and non-centrality parameter scale $= S^2$ has density $$f(x) = \frac{{n/2}^{n/2}}{\Gamma (n/2)} S^n {(1/x)}^{n/2+1} {e}^{-(n S^2)/(2x)}$$

See Also

rchisq for the chi-squared distribution which is the basis for this function.

Examples

Run this code
.Random.seed <- 1:3; rinvchisq(5, df=2)
.Random.seed <- 1:3; 1/rchisq(5, df=2)

.Random.seed <- 1:3; rinvchisq(5, df=2, scale=5)
.Random.seed <- 1:3; 5*2/rchisq(5, df=2)

## inverse Chi-squared is a particular case
x <- 1:10
all.equal(dinvchisq(x, df=2), dinvchisq(x, df=2, scale=1/2))

Run the code above in your browser using DataLab