Pergunta

I am trying to run JAGS using the runjags package and produce customized plots - change colors of the chains (the full model code is in the question https://stats.stackexchange.com/q/62006/5509):

require("runjags")
out2 <- run.jags("Poisson.OD.t.test.txt", params, win.data, nc, inits,
      nb*4/5, ni, nb*1/5)
plot(out2, layout = c(4, 2))

But it seems impossible to change the plot parameters. In ?runjagsclass they write:

The plot method produces trace and density plots (note that these are pre-plotted and stored inside the runjags object, so the usual options to lattice or plot functions are not available).

This seems that the plots are already made in the run.jags call! But that does not seem to allow to change the plot options as well.

Questions:

  1. How to change the plot parameters, like chain colors?

  2. Why do they create plots in the run.jags already? Usually well designed application will separate the logic (model computation) and the outputs. Is there any special reason for that?

Foi útil?

Solução

Usually the largest elements of a runjags class object are the data and RNG states required to continue the model as it is. Unless these are stored inside the class, there isn't a way to continue this where it left off without requiring additional arguments. However, when you have monitored a large number of variables, sometimes the pre-fabricated plots are also quite large - in these cases you can get rid of all the plots (and associated storage problems) by specifying plots=FALSE to the original run.jags() call. Or, you can strip the runjags object down to a bare-bones MCMC list object using (as you might expect) as.mcmc.list().

So to answer your questions: 1) Use as.mcmc.list() first and then use whatever specific plots on these chains you want to 2) The design decision I made at the time was to pre-create all of these plots (on thinned MCMC chains to minimise storage issues) so that the time required to print them was reduced, and so that the convergence diagnostic plots that I typically want to look at quickly are easily at hand. These weren't really (as stated in the help file) intended to be used for anything other than convergence diagnostics. In the future I may look at alternative ways of generating the plots on the fly (using the existing S3 methods), as the code that stores the plots is very old and probably outdated, but it will always be a compromise of speed vs storage. For my purposes, speed nearly always wins out (I'm impatient).

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top