# NOT RUN {
data(chimpanzees)
d <- list(
pulled_left = chimpanzees$pulled_left ,
prosoc_left = chimpanzees$prosoc_left ,
condition = chimpanzees$condition ,
actor = as.integer( chimpanzees$actor ) ,
blockid = as.integer( chimpanzees$block )
)
m <- map(
alist(
pulled_left ~ dbinom(1,theta),
logit(theta) <- a + aj[actor] + bp*prosoc_left + bpc*condition*prosoc_left,
aj[actor] ~ dnorm( 0 , 1 ),
a ~ dnorm(0,2),
bp ~ dnorm(0,1),
bpc ~ dnorm(0,1)
) ,
data=d )
prior <- extract.prior(m,n=1e4)
post <- extract.samples(m)
ps <- par("bty")
par(bty="n")
plot( precis(prior,2) , col.ci="gray" , xlim=c(-3,3.5) , bty="n" )
plot( precis(post,2) , add=TRUE , pch=16 )
par(bty=ps)
# }
Run the code above in your browser using DataLab