Update stanfit object with more iterations

Hello,

I am running a model using rstan and an HPCC cluster, where I time out if the model takes too long to fit. I see that the brms package has an update function to add additional iterations after running a model. Is it possible to add iterations to a stanfit object?

I saw the topic in a previous post (Add iterations to stan fitted object without fully rerunning - similar to update in JAGS?) that uses python. I can attempt that version if that’s the only option, but I’ve only used python a handful of times.

Thank you,
-Wendy

2 Likes

Hi,
there are two issues (with different solutions):

  1. You are able to complete the warmup phase, but need to add more sampling iterations.
  2. Your model does not even complete the warmup phase

In case 1) you should be able to replicate the process from the Python reference with cmdstanr - (see Saving & reusing adaptation in cmdstanr - #44 by mike-lawrence) but also with rstan - you need to get the inverse metric, init values and step sizes from the previous run to start a new run without warmup

Case 2) is a bit more complex as the warmup is relatively complex thing… You might be able to get OK results by chaining together several shorter adaptations. You might also be able to run the individual adaptation windows separately (with the same method for restarting), by appropriately manipulating the init_buffer, term_buffer and window parameters. But I am just guessing and have never really tried doing that myself.

Best of luck with your model!