gibbs_normal function

Gibbs sampling of the normal sampling posterior

Gibbs sampling of the normal sampling posterior

Implements Gibbs sampling for normal sampling with independent priors on the mean and precision

gibbs_normal(s, P = 0.002, iter = 1000)

Arguments

  • s: a list with components y, the observed data, mu0, the prior mean of mu, sigma0, the prior standard deviation of mu, a, the shape parameter of the gamma prior on P, b, the rate parameter of the gamma prior on P
  • P: starting value of the precision parameter
  • iter: number of iterations

Returns

matrix of simulated draws of (mu, P) from the algorithm

Author(s)

Jim Albert

Examples

s <- list(y = rnorm(20, 5, 2), mu0 = 10, sigma0 = 3, a = 1, b = 1) out <- gibbs_normal(s, P = 0.01, iter=100)