Speed up the Rstan run


I submitted my Rstan code to remote server which has multple cores and larger RAM. I have also specific the options:
options(mc.cores = parallel::detectCores())

posterior_compriror <- stan(…, chains= 4, cores = 20)

However, it does not work, the speed at remote server is quite similar to that running at my own laptop.

Could you please give me some inputs?


Rstan parallelizes over the chains, so even if you add cores, it won’t use more than 4. You could run more chains for fewer iterations, if that doesn’t cause you convergence problems.

Besides that, as far as I know currently you can exploit better parallelism only through map_rect: for that, you could start from https://github.com/rmcelreath/cmdstan_map_rect_tutorial.