R seems to be able to output nice summary plots from the bugs and jags objects generated by the functions R2WinBUGS::bugs and R2jags:jags.

However, I am using the rjags package. When I try to plot the results of the function rjags::coda.samples using R2WinBUGS::plot.mcmc.list the results are diagnostic plots (parameter density, chain time series, autocorrelation) for each parameter.

Below is the type of plot that I would like to produce, from Andrew Gelman's tutorial "Running WinBuugs and OpenBugs from R". These were produced by using the plot.pugs.

The problem is that plot.bugs takes a bugs object as an argument, while plot.mcmc.list takes the output of coda.samples.

Here is an example (from the coda.samples):

 LINE.out <- coda.samples(LINE, c("alpha","beta","sigma"), n.iter=1000)

What I need is either

  • a way to generate a similar, information-rich, one-page summary plot similar to the one produced by plot.bugs
  • a function that will convert LINE.out to a bugs object or

enter image description here


closed as off-topic by kjetil b halvorsen, user158565, Peter Flom Dec 17 '18 at 11:23

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – kjetil b halvorsen, user158565, Peter Flom
If this question can be reworded to fit the rules in the help center, please edit the question.


Since there are no answers, I will at least post what I have gotten so far:

The as.bugs.array function in the R2WinBUGS package was created for this purpose. According to the documentation (?as.bugs.array):

Function converting results from Markov chain simulations, that might not be from BUGS, to bugs object. Used mainly to display results with plot.bugs.

Thus, it is possible to obtain a plot from LINE.out in your example, although it does not plot the correct variables:

plot(as.bugs.array(sims.array = as.array(LINE.out)))        

It will take a little bit more work to determine the correct way to transform the LINE.out, and the LINE.samples object from example(jags.samples) may be an easier place to start.


The following seems to work for me:

m <-jags(data=d,inits=i,pars,n.iter=1000,n.chains=3,model.file="foo.txt",DIC=F)
m <- autojags(m)

Here is a reproducible example:

  • 1
    $\begingroup$ That is a helpful clue, but doesn't solve the problem of starting with an mcmc.list (as far as I can tell). $\endgroup$ – David LeBauer Jul 19 '12 at 17:51

Not the answer you're looking for? Browse other questions tagged or ask your own question.