I'm building a series of hierarchical models using R and JAGS, linked using the R2jags library. The runs are fairly long -- from several hours to several days. I've had the sad experience of running some chains that did not converge. In that case, is there a way to extend the chain, rather than starting over?
5 Answers
You can use autojags(currentmodel,n.iter,...)
from R2jags. You can specify the criteria for "convergence" based on $\hat R$.
-
$\begingroup$ Please add explanation what is Rhat. $\endgroup$– mpiktasCommented Aug 3, 2011 at 12:39
-
$\begingroup$ $\hat R$, the potential scale reduction factor, is essentially a scaled version of the estimated variance of the stationary distribution. The variance is estimated as a weighted function of the within and between chain variances. Approximate convergence is reached when $\hat R \approx 1$. Andrew Gelman developed this and a google search will come up with plenty of details. $\endgroup$– scottyazCommented Aug 3, 2011 at 13:02
If there is an option to choose a starting point--yes. You can "continue" an MCMC chain simply by using the last point of the chain as a new starting point.
If a chain has not converged you don't want to use it for inference anyways. You can just continue sampling and save new samples for inference if you use rjags. Then the old iterations would be considered as burn-in. I assume you could do the same with R2jags.
Abe,
Probably you have already solved this, but I think one can simply use the 'update' function provided in the package, as already suggested by Quantitative Historian.
Specifically you may want to use the 'update' function
"In JAGS, however, \updating" a chain in R is straightforward: fit <- update(fit, 1000) replaces fit with 1000 new draws (per chain), treating the values in the original fit as burn-in"
from
http://web.as.uky.edu/statistics/users/pbreheny/701/S13/notes/3-5.pdf