dinvchi: Inverse-Chi distribution.

View source: R/bayesmeta.R

dinvchiR Documentation

Inverse-Chi distribution.

Description

(Scaled) inverse-Chi density, distribution, and quantile functions, random number generation and expectation and variance.

Usage

  dinvchi(x, df, scale=1, log=FALSE)
  pinvchi(q, df, scale=1, lower.tail=TRUE, log.p=FALSE)
  qinvchi(p, df, scale=1, lower.tail=TRUE, log.p=FALSE)
  rinvchi(n, df, scale=1)
  einvchi(df, scale=1)
  vinvchi(df, scale=1)

Arguments

x, q

quantile.

p

probability.

n

number of observations.

df

degrees-of-freedom parameter (>0).

scale

scale parameter (>0).

log

logical; if TRUE, logarithmic density will be returned.

lower.tail

logical; if TRUE (default), probabilities are P(X <= x), otherwise, P(X > x).

log.p

logical; if TRUE, probabilities p are returned as log(p).

Details

The (scaled) inverse-Chi distribution is defined as the distribution of the (scaled) inverse of the square root of a Chi-square-distributed random variable. It is a special case of the square-root inverted-gamma distribution (with \alpha=\nu/2 and \beta=1/2) (Bernardo and Smith; 1994). Its probability density function is given by

p(x) \;=\; \frac{2^{(1-\nu/2)}}{s \, \Gamma(\nu/2)} \Bigl(\frac{s}{x}\Bigr)^{(\nu+1)} \exp\Bigl(-\frac{s^2}{2\,x^2}\Bigr)

where \nu is the degrees-of-freedom and s the scale parameter.

Value

dinvchi()’ gives the density function, ‘pinvchi()’ gives the cumulative distribution function (CDF), ‘qinvchi()’ gives the quantile function (inverse CDF), and ‘rinvchi()’ generates random deviates. The ‘einvchi()’ and ‘vinvchi()’ functions return the corresponding distribution's expectation and variance, respectively.

Author(s)

Christian Roever christian.roever@med.uni-goettingen.de

References

C. Roever, R. Bender, S. Dias, C.H. Schmid, H. Schmidli, S. Sturtz, S. Weber, T. Friede. On weakly informative prior distributions for the heterogeneity parameter in Bayesian random-effects meta-analysis. Research Synthesis Methods, 12(4):448-474, 2021. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/jrsm.1475")}.

J.M. Bernardo, A.F.M. Smith. Bayesian theory, Appendix A.1. Wiley, Chichester, UK, 1994.

See Also

dhalfnormal, dhalft.

Examples

#################################
# illustrate Chi^2 - connection;
# generate Chi^2-draws:
chi2 <- rchisq(1000, df=10)
# transform:
invchi <- sqrt(1 / chi2)
# show histogram:
hist(invchi, probability=TRUE, col="grey")
# show density for comparison:
x <- seq(0, 1, length=100)
lines(x, dinvchi(x, df=10, scale=1), col="red")
# compare theoretical and empirical moments:
rbind("theoretical" = c("mean" = einvchi(df=10, scale=1),
                        "var"  = vinvchi(df=10, scale=1)),
      "Monte Carlo" = c("mean" = mean(invchi),
                        "var"  = var(invchi)))

##############################################################
# illustrate the normal/Student-t - scale mixture connection;
# specify degrees-of-freedom:
df <- 5
# generate standard normal draws:
z <- rnorm(1000)
# generate random scalings:
sigma <- rinvchi(1000, df=df, scale=sqrt(df))
# multiply to yield Student-t draws:
t <- z * sigma
# check Student-t distribution via a Q-Q-plot:
qqplot(qt(ppoints(length(t)), df=df), t)
abline(0, 1, col="red")

bayesmeta documentation built on July 9, 2023, 5:12 p.m.