Tutorials › Bayesian Clinical Trials › Trace Plots For Clinical Trial Parameters

Posterior Computation · Tutorial 130 of 696

Trace Plots For Clinical Trial Parameters

Learn how to construct and interpret trace plots for trial parameters, recognize common warning patterns, and understand what a visually stable trace can and cannot establish.

Intermediate 12 min read

What You'll Learn

  • Identify drift, prolonged sticking, and restricted exploration in parameter traces.
  • Interpret traces for response probabilities, treatment contrasts, and variance parameters.
  • Use chain overlays and parameter-appropriate scales to inspect sampler behavior.
  • Distinguish a stable-looking trace from evidence that a chain has converged.
  • Explain why visual inspection complements, but does not replace, numerical diagnostics.

What a Trace Plot Shows

An MCMC analysis produces an ordered sequence of draws, not an independent sample assembled without regard to order. A trace plot displays the sampled value of a parameter against iteration number. The horizontal axis is the iteration; the vertical axis is the parameter value. A separate line is usually drawn for each chain, with chains distinguished by color or line style.

In a clinical trial, the plotted quantity might be a treatment-arm response probability, a treatment contrast, or a variance parameter. The order matters: a plot of the same values after randomly shuffling them would conceal whether the sampler spent long stretches in one region before moving elsewhere. A trace plot is therefore a visual check on how the chain explores the parameter’s plausible values over time.

Definition: For a parameter \(\theta\), a trace plot graphs the ordered MCMC draws \(\theta^{(1)},\theta^{(2)},\ldots,\theta^{(M)}\) against iteration \(1,2,\ldots,M\). The plotted draws should be identified as pre-warmup or retained draws; interpretation of posterior sampling generally focuses on draws retained after warmup.

The plot should be made for quantities that matter to the analysis. A model may contain many parameters, and acceptable behavior for one parameter does not establish acceptable behavior for another. In a trial model, inspect relevant arm-specific response probabilities and treatment contrasts, as well as variance parameters that control outcome variability or between-group heterogeneity. A derived quantity can also be plotted if it is important to the scientific conclusion.

What a Healthy-Looking Trace Means

A trace that looks stable typically fluctuates around a roughly consistent level, without a persistent upward or downward trend, and visits a reasonably broad range of values. When several chains are shown, they should occupy similar regions rather than remaining separated. “Stable” does not mean that the line is flat, or that every iteration is close to the posterior mean. Posterior draws vary; a line that moves is expected.

The basic justification comes from the intended target distribution. Suppose a chain has reached a stationary regime with posterior distribution \(\pi(\theta\mid y)\), where \(y\) denotes the observed trial data. In this regime, the distribution of a draw does not change with iteration. For any integrable function \(g\), this implies

$$ E\!\left[g\!\left(\theta^{(t)}\right)\mid y\right] = \int g(\theta)\,\pi(\theta\mid y)\,d\theta \qquad\text{for every }t. $$

Thus, a persistent change in the level or spread of the trace can signal that the chain has not settled into a regime consistent with the target distribution. This argument explains why stability is worth checking; it does not prove that a chain has reached the target. An invariant distribution only describes a distribution that the transition rule preserves. It does not guarantee that a chain initialized elsewhere has explored that distribution adequately in the iterations available. The MCMC construction and warmup address different parts of this problem; trace inspection is a practical diagnostic of the resulting draws.

Worked Example: Drift in a Response-Rate Trace

Consider a hypothetical binary-endpoint trial with 60 participants in the active arm and 30 observed responders. With a uniform \(\operatorname{Beta}(1,1)\) prior for the active-arm response probability \(p_A\), the conjugate posterior is \(\operatorname{Beta}(31,31)\), with posterior mean \(31/(31+31)=0.500\). Suppose a trace plot of one chain shows that the draws rise from about 0.30 early on, pass through 0.42, and then fluctuate between about 0.47 and 0.53 later.

The gradual movement toward 0.50 is a drift warning: the early part of the trace does not appear to fluctuate around the same level as the later part. It would be inappropriate to summarize the entire plotted sequence as though all iterations were interchangeable posterior draws. The analyst should check whether the early segment is warmup and inspect the retained trace after warmup. If the retained draws continue to trend, the plot does not support treating them as a settled sample.

The later range is compatible with the posterior’s central region, but that visual compatibility is not proof that the chain explored the full posterior. The posterior mean above is calculated from the specified conjugate model, not estimated from the trace. This comparison is useful because it provides a known reference in this hypothetical example; in a general model the trace alone does not supply a known correct posterior summary.

Recognizing Common Warning Patterns

A trace plot can reveal several distinct problems. They should not be collapsed into one label: different patterns can arise from different features of the model or sampler.

  • Drift: the trace has a sustained upward or downward movement, or a clear change in level or spread across iterations. This suggests that the chain’s behavior has not stabilized over the displayed period. A smooth-looking trend can be subtle, so inspect the full run and not only a short final segment.
  • Long-term sticking: the chain remains at, or very near, the same value for a long run before moving. In Metropolis-type methods, repeated values can occur when proposals are rejected; some repeated draws are normal, but unusually long plateaus may indicate that the chain is moving inefficiently through the posterior.
  • Poor exploration: the trace stays in a narrow region, fails to visit visibly different regions, or different chains occupy disjoint ranges. A narrow trace is not automatically a problem—the posterior might genuinely be concentrated—but it warrants checking against the model, parameter scale, and other diagnostics.
  • Apparent stationarity: the trace fluctuates around a stable level with no obvious drift. This is reassuring as a first visual check, but a chain can look stable while exploring only part of the posterior or while moving so slowly that the plot conceals important dependence.

A trace plot should be examined at more than one visual scale. A long run can hide short episodes of sticking, while a very short window can make ordinary random variation look like drift. Plot iteration on the horizontal axis and retain a clear indication of which draws are warmup. If points are rounded or plotted densely, apparent plateaus may be caused by plotting resolution rather than exactly repeated underlying draws.

Worked Example: Long Stretches of Sticking in a Treatment Contrast

Suppose a hypothetical continuous-endpoint trial defines \(\delta\) as the active-arm mean reduction in systolic blood pressure minus the control-arm mean reduction, in mmHg. Under this definition, a positive \(\delta\) favors the active arm. In one chain, the unrounded trace stays at approximately 2.1 mmHg through a long stretch of retained iterations, then changes briefly to about 2.4 mmHg and again remains nearly unchanged.

The concern is not that the trace is near 2.1 mmHg, nor that it has failed to reach a particular clinical threshold. The concern is its temporal pattern: the chain appears to make few moves during long stretches. If the plotted values are rounded, first check the unrounded draws to determine whether they are truly repeated or merely close after rounding. If they are repeated, compare the pattern across chains and review the sampler’s transition behavior. A plot alone cannot determine whether the narrow range is the true posterior concentration or a failure to explore it.

The units help keep the interpretation grounded: the vertical axis represents a difference in mean blood-pressure reduction, measured in mmHg. It does not represent a probability or a percentage. A flat segment is a diagnostic feature of the computation, not evidence that the treatment effect is known with certainty.

Parameter-Specific Reading: Probabilities and Variances

A response probability is constrained to the interval from 0 to 1. Its trace must stay within those bounds. A chain that repeatedly approaches 0 or 1 may be behaving correctly if the posterior places substantial mass near a boundary, but the scale can make movement difficult to see. If the model samples a transformed quantity, such as the logit of a probability, be clear about which quantity is on the vertical axis: a trace of the logit can take any real value, while a trace of the probability remains between 0 and 1. The two traces describe the same parameter on different scales, but their visual patterns need not look alike.

Variance parameters are positive and often have asymmetric posterior distributions. Their traces may show occasional large excursions even when the center of the distribution is much lower. Plotting a variance on its original scale can compress smaller values when a few draws are large; a logarithmic scale may make multiplicative movement easier to see. State the scale and units clearly. For example, if an outcome is measured in mmHg, its variance is measured in \(\text{mmHg}^2\), whereas its standard deviation is measured in mmHg. A log-scale display changes the axis, not the parameter’s units or scientific definition.

Worked Example: Reading a Variance-Parameter Trace

Suppose a hypothetical continuous-outcome model monitors the residual variance \(\sigma^2\) for an endpoint measured in mmHg. In two consecutive sections of a retained chain, the trace repeatedly visits values around 9, 16, and 25 \(\text{mmHg}^2\), with occasional excursions near 36 \(\text{mmHg}^2\). The sections show similar ranges and no sustained increase or decrease.

The repeated return to a comparable range in both sections is consistent with apparent stability; variation between draws is expected for a posterior distribution. The occasional larger values should not be deleted simply because they make the plot less tidy. They may be meaningful posterior draws, and the raw-scale trace can make the lower values look compressed. A plot of \(\log(\sigma^2)\) can help reveal whether movement is occurring across multiplicative scales, but it should be labelled as a transformed parameter.

This visual assessment is limited: similar-looking sections do not establish that the chain has explored the full posterior, and a plausible-looking variance trace does not validate other model parameters. The analyst should inspect the variance together with the trial’s treatment effects and other important quantities, then use complementary diagnostics.

Chains, Alternatives, and Limits

When multiple chains are available, overlay their traces using the same axis scales. Similar-looking chains that overlap and fluctuate through comparable regions provide more reassurance than a single chain alone. Conversely, a gap between chains or a chain that remains at a distinct level is a warning, even if each separate trace looks locally stable. This visual comparison complements the chain-separation considerations used during initialization; it does not replace them.

Trace plots are qualitative. Rank-normalized R-hat, effective sample size, and Monte Carlo standard errors provide numerical information that a trace cannot provide by itself; autocorrelation plots focus on dependence across lags. These approaches answer related but different diagnostic questions. A trace plot’s strength is that it preserves iteration order and can make time-localized problems—such as a long plateau or gradual drift—visible. Its limitation is that visual judgments depend on plotting choices and may miss subtle or high-dimensional failures.

In particular, there is no universal trace shape that proves convergence. A smooth, noisy line is not automatically good; a rough line is not automatically bad. Posterior concentration, parameter scaling, the number of iterations, and plotting resolution all affect appearance. Diagnostics also cannot repair a misspecified likelihood, an inappropriate prior, or a coding error. Trace inspection assesses the behavior of the computation under the model that was fit; it does not establish that the model is scientifically adequate.

A Practical Inspection Sequence

1
Choose meaningful quantities.
Include important response rates, treatment contrasts, and variance parameters. Label each parameter, its arm or contrast definition, and its units.
2
Show iteration and warmup clearly.
Make clear which draws were retained. Do not mistake a warmup trend for a retained-sample trace, or silently include warmup draws in posterior summaries.
3
Look for temporal patterns.
Check for drift, changes in spread, long plateaus, narrow exploration, and regions that are visited only briefly.
4
Compare chains and scales.
Overlay chains on common axes. For constrained or skewed parameters, consider whether a clearly labelled transformation would expose behavior hidden by the original scale.
5
Follow up rather than declare success.
Investigate warnings and consult numerical diagnostics. A visually stable trace is evidence to consider, not a certificate of convergence.

Common Mistake

A common mistake is to conclude, “The trace looks like a fuzzy horizontal band, so the sampler has converged.” The reasoning is incomplete: a chain can fluctuate within a limited region and still fail to explore other posterior regions, and a visually stable trace can conceal high autocorrelation or subtle between-chain differences. The correction is to describe what the plot actually shows—such as “no obvious drift in the displayed retained draws”—and then assess it alongside chain comparisons and numerical diagnostics. Avoid describing visual stability as proof.

Key takeaway: A trace plot is an iteration-ordered view of MCMC behavior. Use it to identify drift, sticking, and restricted exploration in clinically meaningful parameters, while treating apparent stationarity as a useful but incomplete diagnostic.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A trace of an active-arm response probability rises steadily through the retained iterations. What is the main visual warning, and what should you avoid concluding from the plot alone?
  2. A treatment-effect trace has many long, exactly repeated values. Name one possible explanation and one check that would help interpret the pattern.
  3. Why might a trace of a positive variance parameter be examined on a logarithmic scale? What must remain clear when reporting it?
  4. Two chains each look locally stable, but one stays near a lower range than the other. Is apparent within-chain stability sufficient reassurance?

Solutions. (1) The sustained rise is drift, suggesting that the chain may not have stabilized over the retained period. It does not by itself establish the correct posterior value or prove why the drift occurred. (2) Repeated values may result from rejected proposals in a Metropolis-type update. Check the unrounded draws and review chain behavior and sampler transitions; a trace alone does not establish whether the posterior itself is concentrated. (3) A log scale can make multiplicative movement and smaller values easier to see when a few large values compress the raw-scale display. State that the plotted quantity is \(\log(\sigma^2)\), and give the original variance’s scientific units when interpreting the parameter. (4) No. The difference in ranges is a warning that chains may not be exploring comparable regions; local stability does not rule out separation or inadequate exploration.

Clinical Biostats