Lecture 41

We discussed the use of posteriors to give the Bayesian analog of confidence intervals known as probability intervals using the example of binomial sampling and the beta distribution from the last lecture. We then discussed the problem of finding the proportionality constant in the posterior distribution and the use of MCMC (Monte Carlo Markov Chains) to simulate data without knowing the proportionality constant. The minitab macro we used for the beta distribution is below:


GMacro 
MCMC

name k3 'nA'
let nA = 20

name k4 'alpha'
let alpha = 1
name k5 'beta'
let beta = 1
name k6 'n'
let n = 50
name k7 'r'

Random 1 c1;
Uniform 0.0 1.0.

# c1(k1-1) = c1(k2) contains p_t
#c2(1) contains p*

do k1=2:1000

let k2 = k1 - 1

random 1 c2;
uniform 0 1.

let r = ( (c2(1)**(nA + alpha -1))*( (1 - c2(1))**(2*n - nA + beta - 1) ) )
let r = r / ( (c1(k2)**(nA + alpha -1))*((1 - c1(k2))**(2*n - nA + beta - 1) ) )


if r > 1 
let r = 1
endif

random 1 c3;
uniform 0 1.

if r > c3(1)
let c1(k1) = c2(1)
else
let c1(k1) = c1(k2)
endif

enddo

EndMacro