Rstanarm: How to catch the initialisation error?

I am using stan_glmer to fit a mixed-effect model. I noticed that when one of the four chains failed to initialise, the other three chains initialised fine and kept sampling. As a result, when the model finished sampling, I had samples from the three chains, not four chains.

Is there any way to stop the sampling altogether when some of the chains fail to initialise? The error message here is “Error in sampler$call_sampler(args_list[[i]]) : Initialization failed.”

Ideally, I would like to stop all the chains when some of the chains do not initialise, tweak “init_r”, and start all the chains again. Here, I am not using stan_glmer in an interactive session, and so, it helps a lot if I can programmatically catch the error.

  • Operating System: Debian on Docker
  • rstanarm Version: 2.18.2

The other chains are independent of the one that had an initialization error so they don’t know that they are wasting their time trying to sample. It is better to just start with a lower value of init_r; the default one is too large anyway for a lot of multilevel models.

Thanks Ben.

Do you have a rule of thumb for choosing init_r? Should I choose a lower value if a model has more random effects?

Yes

Thanks again.