Divergent transitions after warm up & Rhat


After I fitting my model, there is a warning of 10 divergent transitions after warm up. However, the Rhat is 1 for all parameters. Should Rhat be an indicator of divergence?



No. Divergent transitions are an indicator of parts of the parameter space that the sampler cannot get to. Rhat just tells you that the chains have similar means.


Thank you so much. Now the terms are much more clear to me:)


Divergences are when Stan can’t follow the Hamiltonian trajectory—the Hamiltonian, which should remain constant, diverges. As @bgoodri says, R-hat just measures that the within-chain means and variances match the cross-chain means and variances. It’s possible for draws to have decent looking R-hat when chains have not fully explored the posterior. Divergences are an additional way of signaling that something may be going wrong.

If you only have a few, increase adapt_delta and potentially lower stepsize (the latter is just the init value, so it’s not as critical if you’re converging to the typical set in all chains already).


Importantly, divergences are a more sensitive diagnostics than R-hat, so often you’ll see indications of problems from non-zero divergences before they manifest as bad R-hats amongst different chains.

For more on how to use divergences see http://mc-stan.org/users/documentation/case-studies/divergences_and_bias.html.


Thank you all for the thorough explanations.