Learn R Programming

ProbBayes (version 1.1)

gibbs_normal: Gibbs sampling of the normal sampling posterior

Description

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

Usage

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

Value

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

Examples

Run this code
# NOT RUN {
s <- list(y = rnorm(20, 5, 2),
  mu0 = 10, sigma0 = 3, a = 1, b = 1)
out <- gibbs_normal(s, P = 0.01, iter=100)
# }

Run the code above in your browser using DataLab