rm(list=ls(all=TRUE)) # setwd("C:/.../anywhere") setwd("C:/kk") library(R2WinBUGS) # Here you introduce your data X=c(4.51,6.22,6.32,6.41,6.54,6.58,6.63,6.68,6.75,6.83,6.87,6.94,6.99,7.08,7.23,7.44) N=length(X) # Here you inform about the names of your variables of data data = list("X","N") # Here you inform about the names of the parameters of the model parameters = c("sigma2","theta") # Here you put the initial values of your chains Inits = list(list(theta=6,sigma2=1),list(theta=0,sigma2=5)) # Or random inits... # Inits = function(){list(theta=rnorm(1),sigma2=rgamma(1,1,.1))} thing <- bugs(data, Inits, parameters, model.file="simple.bug", n.chains=2, n.iter=10000, n.burnin=5000, bugs.directory="C:/WinBUGS14",debug=TRUE) print(thing) attach.bugs(thing) plot(thing)