Hi everyone, I am currently using Stan with R and was wondering if there was any way to set a time limit for sampling. I am using the
sampling() function from the rstan package to obtain posterior samples for my model. But instead of defining the number of samples I would like, is it possible to give how much time I would like to spend sampling?
The reason I ask is that I am using parallel computing clusters and have certain time limits on that
Nope. This is a long requested feature, but it hasn’t landed yet to my knowledge.
It would be really cool to be able to have time limits … or even better have Stan listen to signals from the OS. On clusters processes exceeding resource limits are usually first send a signal to quit and only if they keep running they are being killed forcibly.
My package already has timing in it, so it should be simple to add a timeout. Back in a few minutes…
ezStan::watch_stan() now has an optional
timeout argument. Note that when the timeout is reached, the sampling process is killed, leaving the stan csv with possibly incomplete rows. I have an issue already for making
ezStan::collect_stan() more robust for collecting the results despite such incomplete files, but don’t have time to work on that yet, so in the interim you’ll have to read in the csv files by hand for any chains that hit a timeout. (You can take a look at the source for
ezStan:collect_stan() for guide on how to do this; and feel free to submit a pull request if you work out a robust approach while you do so!)