What a Divergent Transition Signals
Hamiltonian Monte Carlo (HMC) proposes moves by numerically following a trajectory through a posterior distribution. A divergent transition is a warning that the numerical trajectory did not resolve the posterior geometry adequately at some point. In a hierarchical nonlinear mixed-effects (NLME) model, that can happen where the posterior changes sharply over a short distance, so that the numerical integrator cannot accurately follow its curvature using the chosen integration settings.
A divergence is not a statement that a particular parameter value is impossible, nor is it itself evidence that the model is scientifically wrong. It is evidence that the sampler encountered a region where its numerical approximation was unreliable. If divergences occur in consequential parts of the posterior, the resulting draws may not represent that posterior accurately. The location of the divergences is therefore important: a count without parameter context is an incomplete diagnostic.
For a parameter vector \(q\) in unconstrained coordinates, let \(U(q)=-\log \pi(q\mid y)\), where \(\pi(q\mid y)\) is the posterior density for observed data \(y\), up to a constant. With momentum \(p\) and mass matrix \(M\), the Hamiltonian is
In exact Hamiltonian dynamics, \(H\) is conserved. HMC uses a numerical integrator, commonly leapfrog, to approximate those dynamics. Its step-by-step approximation does not conserve \(H\) exactly. Large integration error, especially in a region of rapidly changing curvature, can trigger a divergence flag. The step size and mass matrix are adapted during warmup, but adaptation cannot always make a difficult geometry easy to traverse.
This interpretation assumes that the log posterior and its gradient are defined and sufficiently regular in the region being sampled, and that the model’s likelihood, priors, transformations, and gradients are implemented correctly. If the log density or gradient is incorrect, a divergence may reflect an implementation problem rather than merely a difficult posterior shape. Even with a correct implementation, no finite numerical integration step resolves arbitrarily sharp curvature.
Why Hierarchical Variance Components Can Form Funnels
Consider a centered random-effects model with \(m\) individuals and one random effect per individual:
where \(\eta_i\) is an individual random effect and \(\tau>0\) is its population standard deviation. When \(\tau\) is small, the conditional distribution concentrates the \(\eta_i\) values near zero. When \(\tau\) is larger, a much wider range of random effects is plausible. The joint posterior can consequently have a narrow region at small \(\tau\) and a wider region at larger \(\tau\): a funnel-like shape.
The likelihood contributes to the full posterior, so the prior conditional distribution alone does not determine the exact posterior geometry. Nevertheless, the conditional distribution exposes a source of sharp curvature that can persist in the full model, including in NLME models where the random effects enter nonlinear individual predictions.
The result follows by writing the conditional negative log density, omitting terms that do not depend on \(\eta_i\):
This is a local geometric explanation, not a guarantee that every model with a small variance component will produce divergences. Data information, the prior on \(\tau\), correlations with other parameters, and the parameterization all affect the joint posterior.
Worked Example: How a Small Random-Effect Scale Changes Curvature
Suppose a hypothetical centered NLME model includes a random-effect standard deviation \(\tau\) and one individual effect \(\eta_i\). Compare the conditional curvature at \(\tau=0.20\) and \(\tau=0.02\). Consider \(\eta_i=0.04\) when \(\tau=0.02\).
At \(\tau=0.20\), the conditional curvature in the \(\eta_i\) direction is
At \(\tau=0.02\), it is
The conditional curvature is therefore \(2500/25=100\) times as large at the smaller scale. The proposed effect \(\eta_i=0.04\) is two conditional standard deviations from zero because \(\eta_i/\tau=0.04/0.02=2\). Its quadratic contribution to the negative log density is
This calculation does not establish that the full posterior has a divergence at this point. It shows why the centered conditional geometry can become much sharper as \(\tau\) decreases, making small-scale regions worth checking when divergences are observed.
Parameterization and the Shape of the Funnel
A centered representation samples \(\eta_i\) directly under its conditional distribution given \(\tau\). A noncentered representation writes
In the prior distribution, the \(z_i\) values have a scale that does not shrink with \(\tau\). This can reduce the tight dependence between \(\eta_i\) and \(\tau\) that appears in the centered representation. But the data likelihood is expressed through \(\eta_i\), so a noncentered representation does not remove all possible posterior curvature or guarantee that divergences disappear. Whether it helps depends on how strongly the data inform individual effects relative to the population scale.
A divergence in a centered model near small \(\tau\) can therefore motivate examining a noncentered formulation, but it does not by itself prove that reparameterization is the only or correct remedy. The earlier material on centered and noncentered random-effect parameterizations covers the definitions and trade-offs; here the diagnostic question is whether the divergence locations reveal a problematic region in the chosen representation.
Worked Example: Locating Divergences Across Scale Regions
Suppose a hypothetical sampling run produces 1,000 post-warmup draws and 8 divergence flags. A divergence-marked scatterplot of \(\tau\) and a representative \(\eta_i\) is summarized by the following bins of \(\tau\):
| Region of \(\tau\) | Draws | Divergent draws | Divergent fraction |
|---|---|---|---|
| \(0<\tau<0.02\) | 30 | 6 | 20.0% |
| \(0.02\leq\tau<0.05\) | 70 | 2 | 2.86% |
| \(\tau\geq0.05\) | 900 | 0 | 0% |
The total divergence fraction is \(8/1000=0.008\), or \(0.8\%\). In the smallest-\(\tau\) bin it is \(6/30=0.20\), or \(20.0\%\); in the middle bin it is \(2/70\approx0.0286\), or \(2.86\%\). The pattern is concentrated at small \(\tau\), rather than evenly spread across the range.
The bin fractions are descriptive, not formal independent-sample estimates: MCMC draws are dependent, and a sparse bin can give an unstable fraction. Still, the concentration directs attention to the small-scale region. A scatterplot of \(\tau\) against \(\eta_i\), with divergent transitions marked, can then show whether the flagged points lie in the narrow part of the centered geometry. A plot of \(\tau\) against \(\eta_i/\tau\) can add context about the effects’ sizes relative to their conditional scale. This local pattern warrants investigation; it does not show that the posterior is correct or that all other regions were adequately explored.
Using Parameter Plots to Diagnose Location
To locate a problematic region, plot sampled parameter values and distinguish divergent from nondivergent transitions. Begin with parameters implicated by the model structure: for example, a random-effect standard deviation \(\tau\), individual effects \(\eta_i\), and parameters that enter the same nonlinear prediction. When the scale is suspected, a plot of \(\tau\) against a random effect, or against a standardized effect \(\eta_i/\tau\), can reveal whether the flags cluster near small scales or along a narrow relationship.
A useful plot is not limited to the parameter named in the warning. In an NLME model, a difficult region can involve a variance component and a fixed effect, a pair of correlated random effects, or a residual-error parameter. Examine plausible pairs and, where available, the model’s transformed or unconstrained coordinates. If the flags appear at extreme values, inspect the corresponding log posterior, gradient behavior, and whether the values are scientifically plausible under the model and priors.
A divergence count is often summarized alongside plots, but it is not enough on its own. A small total can still matter if flags repeatedly occur in a distinct region of posterior support. Conversely, a plot that shows no apparent cluster does not prove that the numerical trajectories were accurate: projections can conceal higher-dimensional structure, and a limited number of flagged points may be difficult to interpret visually.
Record the number of post-warmup draws and the number of divergence flags. Check that the plotted points and counts refer to the same draws.
Overlay divergence indicators on pairs of relevant parameters, starting with suspected variance components and associated random effects.
Ask whether the flags concentrate at a small scale, extreme parameter values, or a narrow dependence suggested by the hierarchical model.
Use the pattern to guide investigation of parameterization, scaling, priors, and implementation. A plot locates warnings; it does not certify convergence or identify a unique cause.
Alternatives, Failure Modes, and Limits
Several responses to divergences address different aspects of the computation. A smaller integration step can improve resolution of sharp curvature, but it may require more computation and may not resolve severe geometric variation. A mass matrix can improve scaling across directions, but a single global scaling adjustment may not make a funnel’s changing local scale uniform. A noncentered parameterization changes the geometry of hierarchical effects and may help when the centered representation is difficult. Revisiting a prior or model structure may be warranted if the posterior places substantial support in an implausible or poorly regularized region, but changing the model solely to suppress warning flags is not a sound diagnostic strategy.
These approaches are not interchangeable. Step-size adjustment addresses numerical resolution; mass-matrix adaptation addresses parameter scaling; reparameterization changes the coordinates and dependence structure; model and prior review addresses the probability model itself. The appropriate investigation depends on where divergences occur and whether the model and its gradients are correctly implemented. A divergence should not be treated as a universal instruction to change one particular setting.
- Failure mode: looking only at the percentage. A low overall fraction can hide concentration in a small but important posterior region. Check the locations of the flagged transitions.
- Failure mode: assuming every small variance is a divergence. Small \(\tau\) creates the potential for sharp centered curvature, but data, priors, and parameterization determine the actual posterior geometry. Inspect the run rather than inferring a failure from a parameter value alone.
- Failure mode: treating a divergence as proof of an incorrect model. A correct model can be difficult to integrate numerically. Conversely, a model or gradient implementation error can also cause problems, so check both computation and specification.
- Failure mode: treating the absence of flags as proof of reliable inference. No detected divergences means this diagnostic did not flag a failure; it does not establish that all posterior regions were explored or that other sampling diagnostics are satisfactory.
The central limitation is that divergence diagnostics identify numerical difficulty, not its unique cause or the magnitude of any resulting inferential error. Parameter plots help connect flags to geometry, but they are projections of a potentially high-dimensional posterior. Interpret them with the model structure and other sampling diagnostics, and do not infer that a posterior summary is trustworthy solely because a divergence count is small or zero.
Check Your Understanding
Answer each question, then compare with the solutions below.
- In the centered model \(\eta_i\mid\tau\sim N(0,\tau^2)\), what is the conditional curvature in the \(\eta_i\) direction at \(\tau=0.10\)?
- A run has 12 divergences among 2,000 post-warmup draws. What is the divergence fraction, and why is that number not a complete diagnostic?
- Why might a plot of \(\tau\) against \(\eta_i\), with divergences marked, be more informative than a plot of \(\tau\) alone?
- Does replacing \(\eta_i\) by \(\tau z_i\), with \(z_i\sim N(0,1)\), guarantee that divergences disappear? Explain.
Solutions. (1) The conditional curvature is \(1/\tau^2=1/0.10^2=1/0.01=100\). (2) The fraction is \(12/2000=0.006\), or \(0.6\%\). It does not show whether flags concentrate in a consequential posterior region, and it does not establish that unflagged regions were adequately explored. (3) The joint plot can show whether flagged points occur where a small scale constrains random effects to a narrow region, a relationship hidden by a marginal plot of \(\tau\). (4) No. The noncentered representation can reduce dependence associated with the centered prior geometry, but the likelihood can still induce difficult curvature, and other parameters or implementation problems can also cause divergences.