---
# System prepended metadata

title: Convergence problems - discussion

---

# Convergence problems - discussion

Current plan: 
- have this in the user's guide.
- unite all warnings, then specific advice for divergences/treedepth/ESS/Rhat
    - Which suggestions are most useful for which type of warning? 
    - Few divergences: increase adapt_delta
    - Short computation + treedepth: increase treedepth
- Build on https://mc-stan.org/docs/2_26/reference-manual/divergent-transitions.html and https://mc-stan.org/misc/warnings.html
  - We'll want separate document on pre-runtime warnings
  - Source: https://github.com/stan-dev/stan-dev.github.io/blob/master/misc/warnings.Rmd 
- Additional reparametrizations to mention
  - "non-centering" other distributions than normal
  - QR decompostition / centering  
  - Sum to zero constraint
- Warnings are important, the goal is not to "make them go away"
- Aki: 
  -  when we can ignore warnings. Some place for quick experiments
  - But with final model, you need to handle them! 
  - Some problems are with posterior (not with model)
    - Maybe even posterior vs parametrization
  - degeneracy -> highly varying curvature (of the log)
  - mountain analogy maybe wrong   
    - or discontinuous log-density
    - or floating point inaccuracies 
  - normal distribution - constant curvature of the log (so not normal posterior is an issue)
  - remove "identifiability" -> likelihood is not informative
  - Reparametrization: anything else than draws from normal distribution is suspect (and then give examples)
- Martin: Maybe a separate subsection for brms/rstanarm 

***

So you got:

```
Warning: There were XXXX divergent transitions after warmup.
```

What does it mean? What to do? 

Divergent transitions are a signal that there is some sort of degeneracy; along with high Rhat/low n_eff and "max treedepth exceeded" they are the basic tools for diagnosing problems with a model. Divergences almost always signal a problem and even a small number of divergences cannot be safely ignored.

We should note that resolving modelling issues is generally hard and requires some understanding of probabilistic theory and Hamiltonian Monte-Carlo, see https://discourse.mc-stan.org/t/understanding-basics-of-bayesian-statistics-and-modelling/17243 for more general resources.

## What is a divergent transition?


## Hints to diagnose and resolve divergences


What follows is a list of brief hints that could help you diagnose the source of degeneracies in your model - or at least let you get faster help here on forums. Where they exist, we link to additional resources for deeper understanding. The aim is to provide a birds-eye view of approaches we've had success with in the past, point you to additional resources and give you keywords to search for :-) This is not, and can't be a definitive guide - each degenerate posterior is problematic in its own way and there is no single approach that would always work.

If you fail to diagnose/resolve the problem yourself or if you have trouble understanding or applying some of the hints, don't worry, you are welcome to ask here on Discourse, we'll try to help!





