Since runjags object with all plots is too big, I tried to run.jags
with plot=FALSE
, save the resultant runjags
object into file, restore it in new R session (as out
) and then generate the plots by
out.with_summaries <- extend.jags(out, sample = 0, adapt = 0)
(for this trick see discussion here: https://stackoverflow.com/a/21859618/684229)
However, for unknown reason this re-compiles and adapts the model again! Even when I set the sample = 0, adapt = 0
!
require(runjags)
t1 <- proc.time()
out.sum <- extend.jags(out, sample = 0, adapt = 0)
# Re-compiling rjags model and adapting...
# Calculating the Gelman-Rubin statistic for 4 variables....
# Convergence may have failed for this run for 4 parameters after 500
# iterations (multi-variate psrf = 214.873)
# Finished running the simulation
t2 <- proc.time()
print(t2 - t1)
# user system elapsed
# 345.67 0.08 352.30
It takes a pretty long time just for plotting the graphs, which is pretty annoying. The same happens when I compute the runjags object with plots and then try to get rid of them to store the runjags object small:
t1 <- proc.time()
out.no_sum <- extend.jags(out.sum, sample = 0, adapt = 0, summarise=FALSE, plot=FALSE)
# Loading required package: rjags
# Loading required package: coda
# Loading required package: lattice
# Linked to JAGS 3.3.0
# Loaded modules: basemod,bugs
# Re-compiling rjags model and adapting...
# Finished running the simulation
t2 <- proc.time()
print(t2 - t1)
# user system elapsed
# 327.53 0.05 329.73
Any tips on how to fix this issue (apart for writing my own plotting functions)?
Warning: The second run the extend.jags
function on the same runjags object is already fast. But if you save the runjags object and load it again in a new session, extend.jags
is slow again. It seems that runjags
or JAGS are caching something (but not within the original runjags object).