What to Do About Convergence Problems

Summary

The decision procedure when . The first branch is quantitative and useful: “if , it could just be that the chains have a high but not debilitating autocorrelation, and doubling the lengths of the chains will be enough. On the other hand, if you have already run 1000 iterations and , it is doubtful that running another few thousand will mix the chains.” Beyond that, the instruction is to understand the geometry before acting — and only then choose among stacking, reparameterizing, changing the model, or leaving Stan’s algorithmic framework entirely for locally-adaptive or tempering samplers.

Overview

The trigger and the first decision (Ch. 12.5, p. 234)

“If or effective sample sizes are less than 100, then we will be concerned about poor convergence. At this point there are several possible courses of action.

The most natural step is to run the algorithm longer until and ESS exceed 100. This can make sense if is not too high — for example, if , it could just be that the chains have a high but not debilitating autocorrelation, and doubling the lengths of the chains will be enough. On the other hand, if you have already run 1000 iterations and , it is doubtful that running another few thousand will mix the chains, and some more work might be required.”

Understand the geometry first

“Poor mixing typically arises from the interaction between the posterior geometry and the sampler. Beyond identifying that the Markov chains are not mixing, we need to understand why the posterior frustrates our sampling algorithm.”

Common troubleshooting techniques:

  • “visualizing traceplots during both the warmup and sampling phases”;
  • “examining the log joint density of each chain”;
  • “comparing ‘posterior’ simulations generated by individual chains”;
  • “simplify the model, for example by fixing some parameters and seeing if the sampler successfully fits the simpler model.”

“All these troubleshooting techniques are demonstrated in the planetary motion case study” — Challenge of Multimodality - Differential Equation for Planetary Motion (§30.3).

Main Content

Diagnosing multimodality, and the two cases it splits into

Case 1 — one mode is real, the others are artifacts (Ch. 12.5, p. 234)

“One such pathology is multimodality of the posterior, with each Markov chain staying stuck in one basin of attraction around a local mode. … In such a case, the traceplots can reveal that the Markov chains are stuck, with the region in which they are caught determined by the starting value. Posterior simulations for each chain can further show whether each mode reasonably describes the data.”

The two outcomes of that check:

  • “If this is the case, the model might be degenerate.”
  • “On the other hand, we might find that some modes correspond to unreasonable parameter values which are inconsistent with our observations.”

The planetary motion example: “the traceplots and posterior simulations reveal that only one mode captures realistic parameter values that plausibly describe the data, while the other modes occur in unreasonable regions of the parameter space that contribute negligible probability mass. Studying a simplification of the model then reveals why these minor modes arise.”

The condition on acting:

“Equipped with such an understanding of the posterior geometry — and only then! — we can discard Markov chains stuck in minor modes or refine our initialization scheme, either by constraining the starting values to be within a reasonable region as determined by the prior or with approximate inference such as Pathfinder.”

The emphatic “and only then!” is the section’s whole argument compressed: discarding chains is legitimate only after you know what the discarded mode represents.

Case 2 — multiple modes all carry real mass

“It is also possible for the posterior to have multiple modes which all contribute meaningfully to the posterior probability mass. There exist several strategies to assess whether this is the case:

  • “we can fit variational methods such as Pathfinder to approximately estimate the total mass around each mode and then weight samples from each mode accordingly”;
  • “a similar idea underlies stacking, which uses posterior simulations to do predictive model averaging and average over different chains” (Yao, Vehtari, and Gelman 2022).

“In some cases, these corrections provide reasonable estimates of the posterior. If not, we must consider other approaches to improve computing.”

The four-way taxonomy of difficult geometry

From §12.3 — the classification that determines the remedy

TypeDescriptionRemedy
Disjoint volumes, all but one near-zero mass”An example appears in Chapter 30""judicious choices of initial values, adding prior information or hard constraints, or they can be pruned by approximately estimating the mass in each mode”
Disjoint volumes, trivially symmetriclabel switching in a mixture”standard practice … to restrict the model in some way to identify the mode of interest (Bafumi et al. 2005; Betancourt 2017b), but sometimes it can work better to use a reparameterization” (Stephens 2000)
Disjoint volumes of high mass that are genuinely differente.g. gene regulation with “two distinct regulatory regimes with opposite signs of the effect, while an effect close to zero has much lower posterior density” (Modrák 2018)“more challenging. Options: stacking as an approximate solution (“not completely general as it requires defining a predictive quantity of interest”); a more fully Bayesian alternative is to divide the model into pieces by introducing a strong mixture prior and then fitting the model separately given each of the components; or strong priors ruling out some modes
A single volume with an arithmetically unstable tail—“If you initialize near the mass of the distribution, there should not be problems for most inferences. If there is particular interest in extremely rare events, then the problem should be reparameterized anyway, as there is a limit to what can be learned from the usual default effective sample size of a few hundred to a few thousand”

Stacking to salvage an intermediate situation

The middle case (Ch. 12.4, p. 229)

“In practice, often our MCMC algorithms mix just fine. Other times, the simulations quickly move to unreasonable areas of parameter space … But it is also common to be in an intermediate situation where multiple chains are slow to mix but they are in a generally reasonable range. In this case we can use stacking to combine the simulations, using cross validation to assign weights to the different chains (Yao, Vehtari, and Gelman 2022).

This will have the approximate effect of discarding chains that are stuck in out-of-the-way low-probability modes.

The result from stacking is not necessarily equivalent, even asymptotically, to fully Bayesian inference, but it serves many of the same goals, and is especially suitable during the model exploration phase, allowing us to move forward and spend more time and energy in other parts of Bayesian workflow without getting hung up on exactly fitting one particular model.

In addition, non-uniform stacking weights, when used in concert with traceplots and other diagnostic tools, can help us understand where to focus that effort in an iterative way.”

Note the framing: stacking here is triage, explicitly labeled as not-quite-Bayesian, justified by the opportunity cost of perfecting one model. Same reasoning as Fit Fast, Fail Fast.

Going outside Stan

When the geometry demands a different algorithm (Ch. 12.5, p. 235)

“With some understanding of the posterior geometry, we can try different strategies to improve computation. Strategies include improved adaptation, reparameterizing the model, and changing the model entirely (recall the folk theorem), as well as approximate algorithms.

We may also decide to operate outside of Stan’s standard algorithmic framework:

  • “If we establish that the posterior has varying curvature, we may choose a sampler with a locally adaptive step size” (Bou-Rabee et al. 2025 — WALNUTS; Biron-Lattes et al. 2024).
  • “If we establish that the target is multimodal, we may consider sampling methods designed to jump between modes, such as adaptive Monte Carlo methods with normalizing flows, parallel tempering, and path sampling” (Gabrié, Rotskoff, and Vanden-Eijnden 2022; Syed et al. 2022; Hukushima and Nemoto 1996; Geyer 1991; Yao, Cademartori, et al. 2025).

And the practical bridges that make this cheap:

  • “Parallel tempering now benefits from a black box implementation in the probabilistic programming language Pigeons.jl (Surjanovic et al. 2025), which conveniently can be run on models written in Stan.”
  • “More generally, algorithms outside of Stan can often still use Stan, thanks to the package BridgeStan” (Roualdes et al. 2023).

The structure of the advice is worth noting: the diagnosis determines the algorithm class. Varying curvature → locally adaptive step size. Multimodality → mode-jumping methods. This is only possible because the earlier sections established what the diagnostics mean.

The workflow consolation

“Thinking about workflow, most of the time we are fitting a series of models, which means that if we have poor mixing and don’t fully trust the inferences from a fitted model, we can interpret it in the context of simpler models we have fit before. We can also take an imperfect model and run with it, in the hope that the computational problems will get resolved somewhere in the future models in the sequence.”

This is the answer to the implicit anxiety of the whole chapter: you do not have to solve every computational problem before proceeding, because the sequence of models gives you a reference frame the single model does not.

Examples

Exercise 12.1 — construct the failures yourself (Ch. 12.6, p. 235)

For , , with :

  • (a) With , “give an example of data for which HMC will fail to converge. Explain.”
  • (b) With data alternating , “give an example of a prior for which HMC will fail to converge. Explain.”

The pairing is deliberate: (a) is a data pathology, (b) is a prior pathology, and the same model exhibits both.

Exercises 12.2-12.3 — mapping where the exponential model works (Ch. 12.6, p. 235)

Continuing the declining-exponentials model (12.2) of Remedy 3:

  • (a) Fix and as data; write a function that simulates then fits with flat priors; “run this function for a range of true parameter values and map out the conditions under which the computation mixes well and yields reasonable inferences.”
  • (b) Repeat allowing all parameters to vary.
  • (c) “Discuss how this result — the necessary precision of the prior — changes if the sample size were larger or smaller or with a different range for .”
  • 12.3 “How strong must this prior be to ensure stable estimation? Do some experimentation to figure this out, and then explain the result.”

Connections

  • The “understand the geometry first” instruction is the operational form of the folk theorem: a symptom is not a diagnosis.
  • The four-way geometry taxonomy is what makes Approximate Algorithms and Approximate Models a reasoned choice rather than a surrender — different geometries call for different approximations.
  • Interpreting an imperfect fit “in the context of simpler models” is Comparing Models Visually doing computational duty.

See Also