if (FALSE) {
library(coda)
scoreBoston<-scoreparameters("bge",Boston)
ordershort<-list()
#run very short chains -> convergence issues
ordershort[[1]] <- sampleBN(scoreBoston, algorithm = "order", iterations=2000)
ordershort[[2]] <- sampleBN(scoreBoston, algorithm = "order", iterations=2000)
codashort_edges<-bidag2codalist(ordershort,edges=TRUE,pdag=TRUE,p=0.05,burnin=0.2,window=10)
gd_short<-gelman.diag(codashort_edges, transform=FALSE, autoburnin=FALSE, multivariate=FALSE)
length(which(gd_short$psrf[,1]>1.1))/(length(gd_short$psrf[,1]))
#=>more MCMC iterations are needed, try 100000
}
Run the code above in your browser using DataLab