rinvgamma2 {sirt}R Documentation

Inverse Gamma Distribution in Prior Sample Size Parameterization

Description

Random draws and density of inverse gamma distribution parameterized in prior sample size n0 and prior variance var0 (see Gelman et al., 2014).

Usage

rinvgamma2(n, n0, var0)

dinvgamma2(x, n0, var0)

Arguments

n

Number of draws for inverse gamma distribution

n0

Prior sample size

var0

Prior variance

x

Vector with numeric values for density evaluation

Value

A vector containing random draws or density values

References

Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A., & Rubin, D. B. (2014). Bayesian data analysis (Vol. 3). Boca Raton, FL, USA: Chapman & Hall/CRC.

See Also

MCMCpack::rinvgamma, stats::rgamma, MCMCpack::dinvgamma, stats::dgamma

Examples

#############################################################################
# EXAMPLE 1: Inverse gamma distribution
#############################################################################

# prior sample size of 100 and prior variance of 1.5
n0 <- 100
var0 <- 1.5

# 100 random draws
y1 <- sirt::rinvgamma2( n=100, n0, var0 )
summary(y1)
graphics::hist(y1)

# density y at grid x
x <- seq( 0, 2, len=100 )
y <- sirt::dinvgamma2( x, n0, var0 )
graphics::plot( x, y, type="l")

[Package sirt version 4.1-15 Index]