if (interactive()) {
# define some simple BUGS model as an R function
# note the use of %_% to include a truncation
mod = function() {
# PRIORS
mu ~ dnorm(0,0.001) %_% T(0,)
sig ~ dunif(0,10)
tau <- 1/sig^2
# LIKELIHOOD
for (i in 1:n) {
y[i] ~ dnorm(mu, tau)
}
}
# write model to a text file to be called by BUGS/JAGS
write_model(mod, "model.txt")
}
Run the code above in your browser using DataLab