# Make up some coin flips! # Feel free to change these numbers n <- 100 # the number of flips x <- 63 # the number of heads # Specify the prior distribution alpha <- 1 beta <- 1 p ~ dnBeta(alpha,beta) # Define moves for our parameter, p moves[1] = mvSlide(p,delta=0.1,tune=true,weight=1.0) moves[2] = mvScale(p,lambda=0.1,tune=true,weight=1.0) # Specify the likelihood model k ~ dnBinomial(p, n) k.clamp(x) # Construct the full model my_model = model(p) # Make the monitors to keep track of the MCMC monitors[1] = mnModel(filename="binomial_MCMC.log", printgen=10, separator = TAB) monitors[2] = mnScreen(printgen=1000, p) # Make the analysis object analysis = mcmc(my_model, monitors, moves) # Run the MCMC analysis.burnin(generations=10000,tuningInterval=200) analysis.run(100000) # Show how the moves performed analysis.operatorSummary() q()