model {
y <- 1
###################################
y ~ dbern(theta.true)
theta.true <- theta[coin]
coin ~ dcat(p[])
for(i in 1:3) {
p[i] <- 1/3
theta[i] <- 0.25*i
coin.prob[i] <- equals(coin, i)
}
}
node mean sd MC error 2.5% median 97.5% start sample
coin.prob[1] 0.1662 0.3723 0.001141 0.0 0.0 1.0 1 100000
coin.prob[2] 0.3342 0.4717 0.001435 0.0 0.0 1.0 1 100000
coin.prob[3] 0.4997 0.5 0.001491 0.0 0.0 1.0 1 100000
Predicting a new observation...
model {
y <- 1
###################################
y ~ dbern(theta.true)
Y.pred ~ dbern(theta.true)
theta.true <- theta[coin]
coin ~ dcat(p[])
for(i in 1:3) {
p[i] <- 1/3
theta[i] <- 0.25*i
coin.prob[i] <- equals(coin, i)
}
}
node mean sd MC error 2.5% median 97.5% start sample
Y.pred 0.5832 0.493 0.001611 0.0 1.0 1.0 1 100000
theta.true 0.5834 0.186 5.687E-4 0.25 0.5 0.75 1 100000