#---------------------------------------------------- # Starting with JAGS: a simple MC # (it is not the principle use of JAGS, but just to check the # installation and get familiar with the sintax) # # GdA 26/1/2016 #---------------------------------------------------- library(rjags) #------------ model ---------------------------- model = "temp_model.bug" write(" model { n ~ dpois(100) p ~ dunif(0.1, 0.9) x ~ dbin(p, n) y <- x^p } ", model) jm <- jags.model(model) # define the model chain <- coda.samples(jm, c("n","p","x", 'y'), n.iter=10000) # sampling print(summary(chain)) plot(chain)