Search code examples
stan

Repeating rstan::stan() by parallel calculation


I try to validate the model. I replicate the estimates by rstan::stan().

Each fitting is not related each other and thus in principle, it probably possible to calculate by parallel.

Is there such package to calculate rstan::stan() by parallel for independent many datasets.


Solution

  • No.

    Expanding on that answer, you can use the parallel processing facilities of R to set up many calls. If you want to use the same model for each one, compile the Stan program using stan_model() and then replace the call to stan() with a call to sampling(). That'll avoid recompilation. We generally recommend using CmdStan for large-scale computing as it doesn't have the memory overhead of R and there's less to go wrong with I/O, system crashes, etc. Then you can spread out easily over multiple machines.

    Also, each chain will run in parallel if you follow the instructions you get when using library(rstan).