Divergences in a non-centered computational model

Sorry but I won’t be able to comment on the specific model. Instead let me offer some general advice.

Sampling in Stan is done on an unconstrained scale, so the apparent geometry on the constrained scale can sometimes be misleading. You can run with the diagnostic_file option to save the unconstrained values and look for problems there to avoid any confusion.

Trying to debug a model that takes days to run is going to be a pain no matter the circumstance. The best thing that you can do is back up and restart with a simpler model, adding structure incrementally until something breaks. This may include removing hierarchical structure, heterogeneity in general, or subjects. Small models will be faster to iterate on and easier to explore for debugging purposes.

Hierarchical priors are rife with degeneracies that can cause divergences. The standard centering/non-centered choice concerns how the individual parameters interact with the population parameters (Gaussian location and scale). But population parameters themselves can also be degenerate when there are few individuals or little day per individual. Make sure to look at those pairs plots, too.

Centering/non-centering is done for each individual one at a time, not for all the individuals altogether. If you have strong imbalances in your data then you might have to center some individuals and non-center others.

As @stijn notes, if you see the “horns” then your priors are definitely way too wide. This doesn’t necessarily mean that “boundary” effects are a concern, but it will require much more out of your data to identify the model as a whole. And because binary data is so weakly informative that might require way more data than you expect.

3 Likes