I am currently running functions such as stan_glm
and stan_glmer
from the rstan
package in R
. I am calling each function 1000 times, and it turns out that about 75% of these runs result in an warning such as:
Warning messages:
1: There were 184 divergent transitions after warmup. Increasing adapt_delta above 0.95 may help. See
http://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
2: There were 1 chains where the estimated Bayesian Fraction of Missing Information was low. See
http://mc-stan.org/misc/warnings.html#bfmi-low
3: Examine the pairs() plot to diagnose sampling problems
4: Markov chains did not converge! Do not analyze results!
I would like to create a while loop that re-runs the function until I come across a run without an warning. Is there a way to flag or detect such warning messages as the one above? Thanks.