Why Trace Plots Matter
A joint-model posterior can involve association parameters, baseline hazard terms, and random-effects variance components, all sampled by an MCMC algorithm. A trace plot puts sampled values in iteration order: it can reveal whether a chain appears to be drifting, repeatedly staying at the same value, or visiting only a narrow part of the parameter’s plausible range. These are practical warning signs that a chain may not yet be exploring its target distribution well.
A trace plot is a diagnostic display, not a test that certifies convergence. A plot that looks steady cannot establish that a chain has explored every important region of the posterior. Its value is that it makes some problems visible early, so a posterior summary is not accepted uncritically.
In a shared-random-effects joint model, \(\alpha\) can denote an association coefficient linking a longitudinal feature to the event hazard. Write \(\lambda_j\) for a baseline hazard rate in interval \(j\) of a piecewise-exponential model, and \(\sigma_b^2\) for a random-effects variance component. These parameters have different meanings and scales, so inspect their traces separately. A trace should be labelled with the parameter, chain, scale, and—where relevant—units.
Plot the retained draws in their original order, usually with a different colour or panel for each chain. Do not sort values before plotting: sorting destroys the sequence information that makes a trace useful. If the parameter is constrained, such as \(\lambda_j>0\) or \(\sigma_b^2\geq 0\), its trace must respect that constraint. It can be useful to view a positive parameter on its natural scale and on a transformed scale, but state clearly which is shown. For instance, \(\log(\lambda_j)\) has no rate units, while \(\lambda_j\) is a rate.
What a Trace Should Show
When a chain is sampling a stationary posterior distribution, its values fluctuate around a stable range rather than showing a persistent systematic movement across iterations. A stationary chain does not have to look flat: posterior uncertainty creates variation, and successive draws can be dependent. Nor does every short upward or downward run imply a problem. The relevant concern is a sustained shift, a long plateau, or an apparent failure to visit portions of the range that other chains visit.
A short justification clarifies why drift is concerning. Let \(\pi\) be the posterior distribution targeted by the sampler and \(P\) its transition rule. If the chain has reached stationarity, then \(\pi\) is invariant under \(P\): a draw with distribution \(\pi\), followed by one transition, still has distribution \(\pi\). Thus, for a parameter with finite posterior mean,
The equality does not say that each realized value, or even every short segment average, must be constant. It says there is no systematic change in the marginal distribution from one stationary iteration to the next. A persistent change in the trace is therefore a reason to investigate initialization, warmup, sampler behaviour, or difficult posterior geometry. Conversely, a finite trace can look steady by chance even if the chain has not reached the relevant parts of the posterior. Visual inspection can flag concerns, but it cannot prove stationarity.
Worked Example: A Rising Association-Parameter Trace
Suppose a hypothetical model has one retained chain for the association coefficient \(\alpha\), measured as the change in log hazard per one-unit increase in the longitudinal feature. The first six plotted draws are \(0.10, 0.16, 0.21, 0.27, 0.32, 0.37\). The values are all plausible as numbers, but their order shows a consistent increase.
A simple descriptive check compares the first and last three draws:
The difference is \(0.320-0.157=0.163\) log-hazard units per feature unit. With only six draws, this calculation is not a convergence test; it merely makes the visible shift explicit. If a longer trace shows the same sustained movement, the chain should not be treated as having convincingly explored a stable posterior range. Check that warmup was handled appropriately, inspect other chains, and investigate the sampler and model before interpreting a posterior summary. The upward trace does not by itself establish that the true association is positive.
Reading Hazard and Variance Traces
Baseline hazard parameters can be difficult to inspect because several interval-specific rates may have different posterior ranges and can be correlated. Plot each \(\lambda_j\) with its interval identified. If a log-rate is sampled, a trace of \(\log(\lambda_j)\) is often easier to display when the rate spans orders of magnitude; exponentiating a plotted value restores the rate on its original scale. A stable trace for one interval does not guarantee that other hazard terms are well explored.
Worked Example: A Sticking Baseline Hazard Trace
In a hypothetical piecewise-exponential model, consider the log baseline hazard for one interval, \(\eta_2=\log(\lambda_2)\). Eight consecutive retained draws are \(-2.30,-2.30,-2.30,-2.30,-1.61,-1.61,-1.61,-1.61\). The plotted trace has two long plateaus. On the natural scale, the corresponding rates are approximately \(e^{-2.30}=0.100\) and \(e^{-1.61}=0.200\) per year.
The first four log-rate draws average \((-2.30-2.30-2.30-2.30)/4=-2.30\); the last four average \((-1.61-1.61-1.61-1.61)/4=-1.61\). The change is \(0.69\) log units, or a factor of approximately \(e^{0.69}=1.99\) in the rate. Repeated identical values can occur in a Metropolis update when proposals are rejected, so this pattern is a plausible sign of chain sticking. It does not identify the cause by itself: the proposal scale, posterior geometry, or other sampler settings may need investigation. Eight draws are far too few to judge the full run, but the plateaus are a clear reason to inspect a longer trace and other relevant parameters.
Variance components need particular care because they are nonnegative and their posterior can concentrate near zero or have a long right tail. A chain that spends time near zero is not automatically stuck: that may be a real feature of the posterior. Concern arises when the trace stays in one narrow region for a long time and does not visit other regions that are plausible or visited by other chains. Inspecting both \(\sigma_b^2\) and \(\sigma_b=\sqrt{\sigma_b^2}\) can aid interpretation, but the transformation changes the scale and shape of the displayed distribution.
Worked Example: A Variance Component That Changes Range
Suppose a hypothetical chain for the random-intercept variance \(\sigma_b^2\), in squared biomarker units, has eight consecutive draws: \(0.04,0.05,0.04,0.05,0.05,0.18,0.32,0.45\). The first four average \((0.04+0.05+0.04+0.05)/4=0.045\). The last four average \((0.05+0.18+0.32+0.45)/4=0.250\). The displayed sequence moves from a narrow near-zero range to substantially larger values.
This pattern is a warning of possible drift or poor exploration, not proof that the variance is large or that the model is wrong. For scale, the square root of the last draw is \(\sqrt{0.45}=0.671\) biomarker units; the square root of \(0.04\) is \(0.200\) biomarker units. Plotting the standard deviation would therefore show the same draws as \(0.200,0.224,0.200,0.224,0.224,0.424,0.566,0.671\), approximately. The transformation preserves the ordering but changes distances. A longer run and comparison with other chains are needed before deciding whether the movement reflects ordinary posterior variation or inadequate sampling.
Comparing Chains and Other Displays
Overlaying traces from multiple chains makes it easier to see whether they visit broadly similar ranges and whether one chain behaves differently. Use distinct colours, clear labels, and a common scale for the same parameter. If chains were initialized at different values, early separation may reflect initialization; focus on the retained portion after warmup, while still watching for later separation or persistent chain-specific patterns. A single-chain trace cannot reveal disagreement between chains.
Trace plots answer a different question from marginal posterior plots. A histogram or density plot shows how often values occur across a chain but discards their order: it can look smooth even when the chain spent a long time stuck and then moved to a different region. A running mean retains some order information, but averaging can hide local sticking and abrupt transitions. Use these displays as complements, not substitutes. Numerical convergence and sampling diagnostics provide additional information beyond visual inspection; a trace alone does not quantify sampling precision or establish agreement.
For a joint model, a practical review should include the association parameter or parameters, each relevant baseline hazard term, and variance components that affect the shared random effects. A sampler can behave differently across parameter blocks. Also inspect important derived quantities if they are central to interpretation, clearly defining their calculation. Keep axes and transformations consistent when comparing chains for a given quantity, and do not infer a parameter’s meaning from the shape of its trace alone.
A Practical Inspection Sequence
Identify the parameter, its units or transformation, chain labels, and the iterations shown. Verify that warmup is not being mistaken for retained sampling.
Check for long upward or downward movement, abrupt shifts, long plateaus, and ranges that appear truncated. Treat short runs as prompts to inspect, not automatic failures.
Look for persistent separation or a chain that explores a visibly different range. Check several parameters rather than relying on one reassuring panel.
If a warning sign persists, review model and sampler behaviour, consider whether parameterization or tuning needs attention, and run suitable additional diagnostics. Do not remove inconvenient draws simply to make the plot appear stable.
Common Pitfalls and Limitations
- Calling a trace “converged” because it looks like a fuzzy band. A chain can remain in one region and produce a visually steady trace while missing another important region. Visual stability is reassuring only in a limited sense and is not proof of convergence.
- Treating every repeated value as an error. Repeated values can result from rejected proposals in a valid sampler. Long plateaus or repeated sticking are warning signs to investigate, not proof of a particular implementation fault.
- Ignoring the parameter scale. A hazard rate, log hazard, variance, and standard deviation have different scales and interpretations. Label the scale and units, especially when comparing plots.
- Reading a marginal plot as if it preserved iteration order. A histogram can conceal when values were sampled. Use the trace to inspect sequence patterns and the marginal display to inspect the distribution’s shape.
- Assuming one well-behaved parameter represents the whole model. Association, hazard, and variance terms may mix differently. Inspect parameters relevant to the scientific interpretation and model structure.
Trace plots are most useful as an early, interpretable screen for problems that can undermine posterior summaries. They are limited by the finite run, subjective visual judgment, and their inability to measure sampling precision. A good-looking trace supports continued evaluation; it does not replace further diagnostics or careful review of the model and computation.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions below.
- What is the horizontal axis of a trace plot, and why should the draws not be sorted before plotting?
- A trace of a log hazard is flat for many iterations and then shifts. Name one possible explanation and one conclusion that cannot be drawn from the plot alone.
- A variance trace spends much of its time near zero. Does that alone show chain sticking? Explain.
- Why might a marginal density plot look acceptable even when the trace reveals a problem?
- Two chains for the same association coefficient occupy visibly different ranges throughout the retained run. What is the appropriate diagnostic response?
Solutions. (1) The horizontal axis is retained iteration, which preserves the order in which the sampler generated the draws; sorting would erase trends and plateaus. (2) Repeated values may reflect rejected proposals or another sampling difficulty, but the plot alone does not establish the cause or prove nonconvergence. (3) No. A posterior concentrated near zero can produce such a trace; concern requires evidence of limited movement or failure to explore other plausible regions. (4) A marginal density discards iteration order, so it can combine values from separated stretches and conceal long plateaus or shifts. (5) Treat the persistent separation as a warning, inspect initialization, model and sampler behaviour, and use additional diagnostics; do not claim agreement or convergence based on either trace alone.