# NOT RUN {
data(reedfrogs)
reedfrogs$pred_yes <- ifelse( reedfrogs$pred=="pred" , 1 , 0 )
# map model fit
# note exp(log_theta) to constrain theta to positive reals
m <- map(
alist(
surv ~ dbetabinom( density , p , exp(log_theta) ),
logit(p) <- a + b*pred_yes,
a ~ dnorm(0,10),
b ~ dnorm(0,1),
log_theta ~ dnorm(1,10)
),
data=reedfrogs )
# map2stan model fit
# constraint on theta is passed via contraints list
m.stan <- map2stan(
alist(
surv ~ dbetabinom( density , p , theta ),
logit(p) <- a + b*pred_yes,
a ~ dnorm(0,10),
b ~ dnorm(0,1),
theta ~ dcauchy(0,1)
),
data=reedfrogs,
constraints=list(theta="lower=0") )
# }
Run the code above in your browser using DataLab