Add iterations to stan fitted object without fully rerunning - similar to update in JAGS?

Is it possible to add iterations to a fitted stan model that did not converge - without running the entire model?

For example, in JAGS one can call update on a model fit to run additional warmup iterations if additional warmup is needed, or one can call jags.samples to get new samples if additional samples are needed (generic code below). This helps to reduce runtime as one doesn’t have to start over.

mymod <- jags.model(file = ‘myfile.txt’, data = XX, …)

update(mymod, n.iter = 100)

mysamps <- coda.samples(mymod, n.iter = 1000)

  • Look at convergence - effecive sample size low or parameters are not stable
  • Update the model further and get new samples (starts at iteration 1101)

update(mymod, n.iter = 500)
mysamps2 <- coda.samples(mymod, n.iter = 2000, thin = 3)

Is this possible in STAN using rstan?

My hour of searching has turned up nothing - and all documents suggest that one has to run the entire model again. With large models on big data that take hours to run - this is a downside.

Something like this is possible

This can be done with PyStan and CmdStan (CmdStanPy, CmdStanR) and maybe with RStan.

Needs a bit of manual work if not on Python (ArviZ handles the concatenation --> maybe posterior package can do this on R. Or just combine CSV files for CmdStan)

2 Likes

Thank you. I was hoping to skip the warmup iterations and just add more post warm-up iterations. This appears to simply fit two models and then add the posteriors together. That would of course save time over simply running the entire model again - so is a viable option. I can handle that in R - it is simple to concatenate them.

No, it skips warmup in the loop (or warmup = 0 and the trained parameters are given for the sampler --> stepsize, init, inverse metric).