I am running a simulation with a model written in Stan. In extreme scenarios, the model have convergence issues. Is there a way to save the convergence status into a variable so that I can look at the frequency the non-convergence with the default setting?
It’s not clear to me exactly what the problem is. Are you running simulation with different parameter values and then doing inference on those, and that’s where you are getting convergence issues, or do you mean something else by convergence issues?
I am simulate a design, which then use stan models for analysis. The simulation was okay most of the time, except a few cases where there are convergence issues. I want to get a sense of how many times this convergence issue arise. Most of the time the convergence an be handled by using a slightly different model. I just want to know the frequency. How can I save the warnings I got directly from sampling statement in rstan? Thanks!
If I understand correctly i’s not the MCMC chain that has convergence issues, but something in the model within each iteration for some sets of parameters. I still don’t know specifically what kind of convergence issue it is, since I don’t know what you mean by simulating a design, but usually you would get a prediction from your model for whatever parameter values.
If these issues are causing divergent transitions in HMC, that is stored in the output and you can see whether a sample has divergences or not looking into the
divergent__ column. If somehow that does not cause divergent transitions (for instance the proposal is rejected outright because of a zero likelihood) then you may only get a warning on the screen. I am not sure about rstan, but cmdstan creates an error file where you can look at all those messages, if you don’t get one of those you can just send the screen output to a file and then look into how many warnings you get there.