rbayesianjagsrunjags

extending burn-in period after JAGS model has been run in runjags for R


The runjags package for R is fantastic. The parallel capabilities and the ability to use the extend.jags function make my life so much better. However, sometimes, after I run a model, I realize the burn-in phase should be have been longer. How can I trim extra samples out of my run.jags output, so I can re-estimate my parameter distributions and check for convergence?

jags.object <- run.jags(model, n.chains=3, data=data, monitor =c('a','b'), sample=10000)

Solution

  • There is currently no way to do this within runjags unfortunately, so you will have to work with the underlying mcmc.list object - something like:

    library('coda')
    mcmc.object <- as.mcmc.list(jags.object)
    niter(mcmc.object)
    windowed.object <- window(mcmc.object, start=10001)
    summary(windowed.object)
    

    Note that the start (and end) arguments of window.mcmc include the burn in phase, so if you have 5000 burn in + 10000 samples then this code gives you iterations 10001:15000

    However, a window method for the runjags class would be a good idea, and hopefully something that will appear soon!

    [It may also be worth noting that you can use the combine=FALSE argument with extend.jags to drop the entire first lot of iterations, but this obviously requires re-sampling new iterations so not exactly what you want.]

    Also - thanks for the kind words about the package - feedback and feature suggestions are always welcome at https://sourceforge.net/p/runjags/forum/general/ :)