# clears workspace: rm(list=ls()) setwd("C:/Users/EJ/Dropbox/EJ/temp/BayesBook/OrderRestrictions") #library(R2WinBUGS) #bugsdir = "C:/Program Files/WinBUGS14" library(R2jags) k <- 5 data = list("k") # to be passed on to WinBUGS # parameters to be monitored: parameters = c("theta1","theta2") # The following command calls WinBUGS with specific options. # For a detailed description see Sturtz, Ligges, & Gelman (2005). samples = jags(data, inits=NULL, parameters, model.file ="OrderRestrictions.txt", n.chains=3, n.iter=10000, n.burnin=1000, n.thin=1) theta1 <- samples$BUGSoutput$sims.list$theta1 theta2 <- samples$BUGSoutput$sims.list$theta2 #for encompassing method, which works: #theta1 <- theta1[which(delta>0)] #theta2 <- theta2[which(delta>0)] iterations <- sample(c(1:length(theta1)),1000) plot(theta1[iterations],theta2[iterations]) #delta <- theta1-theta2 #plot(density(delta))