Skip to contents

Exact conjugate update for iid N(mu, sigma^2) data under the prior sigma^2 distributed Inv-chi2(nu0, sigma0^2) and mu given sigma^2 distributed N(mu0, sigma^2/kappa0) – the (mu, sigma^2) parameterization of the normal-inverse-gamma family. Posterior parameters (Gelman et al., BDA3, Section 3.3, Eq. 3.8): \(\mu_n = (\kappa_0 \mu_0 + n \bar y)/(\kappa_0 + n)\), \(\kappa_n = \kappa_0 + n\), \(\nu_n = \nu_0 + n\), \(\nu_n \sigma_n^2 = \nu_0 \sigma_0^2 + (n-1) s^2 + \kappa_0 n (\bar y - \mu_0)^2 / (\kappa_0 + n)\). The marginal posterior of mu is t with nu_n degrees of freedom, centre mu_n and scale^2 sigma_n^2/kappa_n; the posterior predictive for one new observation has scale^2 sigma_n^2 (kappa_n + 1)/kappa_n.

Usage

Nignst(y, mu0, kappa0, nu0, sigma0_sq)

Arguments

y

Observations.

mu0

Prior location of mu.

kappa0

Prior pseudo-count for the mean.

nu0

Prior degrees of freedom for sigma^2.

sigma0_sq

Prior scale of sigma^2.

Value

List with estimate, mu_n, kappa_n, nu_n, sigma_n_sq, mu_scale_sq, pred_scale_sq, n, ybar, s_sq, method.

References

Gelman, A., Carlin, J. B., Stern, H. S., Dunson, D. B., Vehtari, A. and Rubin, D. B. (2013), Bayesian Data Analysis, 3rd ed., Chapman and Hall/CRC, Section 3.3, Eqs. 3.7-3.8.

Examples

set.seed(10)
y <- rnorm(50, 3, 2)
Nignst(y, mu0 = 0, kappa0 = 1, nu0 = 1, sigma0_sq = 1)[c("mu_n", "sigma_n_sq")]
#> $mu_n
#> [1] 2.27197
#> 
#> $sigma_n_sq
#> [1] 3.007742
#>