Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Posterior Predictive Checks Of Biomarker Trajectories

Model Diagnostics · Tutorial 608 of 697

Posterior Predictive Checks Of Biomarker Trajectories

Learn to design and interpret posterior predictive checks that assess whether a fitted joint model reproduces important features of longitudinal biomarker trajectories.

Advanced 11 min read

What You'll Learn

  • Define posterior predictive replication for the longitudinal component of a fitted joint model.
  • Distinguish subject-conditional replication from replication for new subjects.
  • Calculate and compare trajectory slopes, ranges, extrema, and within-subject variability.
  • Estimate posterior predictive tail areas and interpret them as diagnostic summaries.
  • Recognize design, missingness, and model features that can make a check misleading.

Why Replicate Biomarker Trajectories?

A fitted joint model may describe an average biomarker trend and account for subject-specific deviations, yet still fail to reproduce features that matter in the observed data. For example, it may smooth away unusually steep changes, generate too narrow a range of measurements, or underestimate short-term variation around a subject’s trajectory. Posterior predictive checks examine these features by asking: if the fitted model could generate another data set like this one, would that data set look like the observed biomarker data in the ways we care about?

The check is a model diagnostic, not a test that proves the model is correct. It depends on the chosen summaries, the fitted model, and what is held fixed when data are replicated. Here the focus is on longitudinal biomarker trajectories: their slopes, ranges, extrema, and within-subject variability. Replicated event histories are a separate diagnostic target.

Definition and Replication Setup

Let \(Y_{ij}\) be the biomarker measurement for subject \(i\) at time \(t_{ij}\), where \(i=1,\ldots,n\) and \(j=1,\ldots,n_i\). Write \(D\) for the observed joint data, including the biomarker measurements and event information, and let \(\theta\) denote the joint-model parameters. A typical longitudinal submodel has conditional distribution

$$ Y_{ij}\mid b_i,\theta \sim f_Y\!\left(\,\cdot\mid m_i(t_{ij};b_i,\theta),\theta\right), $$

where \(b_i\) is the subject-specific random effect and \(m_i(t;b_i,\theta)\) is the modelled biomarker trajectory. For example, a Gaussian marker model might set \(Y_{ij}=m_i(t_{ij};b_i,\theta)+\epsilon_{ij}\), with \(\epsilon_{ij}\) having the error distribution specified by the model. A joint model also has an event-time component; that component contributes information to the fitted posterior but does not mean that this particular check must simulate new events.

Definition: A posterior predictive replicate of the biomarker data is generated by drawing parameters and latent effects from their posterior distribution given \(D\), then drawing new marker measurements from the fitted longitudinal submodel. A posterior predictive check compares a chosen summary of those replicated measurements with the same summary of the observed measurements.

For a subject-conditional check, draw \((\theta^{(s)},b_1^{(s)},\ldots,b_n^{(s)})\) from the fitted posterior \(p(\theta,b_1,\ldots,b_n\mid D)\), then draw replicated values \(Y_{ij}^{\mathrm{rep},(s)}\) at the observed subjects’ measurement times and covariates. This asks whether the model reproduces the data for these subjects, using their posterior-informed latent effects. For a new-subject check, draw fresh effects \(b_i^{\mathrm{rep},(s)}\) from the population random-effects distribution implied by \(\theta^{(s)}\), then generate marker measurements. That asks whether the model can reproduce trajectories for subjects drawn from its population. The two checks target different aspects of fit and should not be treated as interchangeable.

Unless the visit or missingness process is itself part of the model and is being checked, the usual trajectory comparison holds the observed measurement schedule fixed. In particular, a replicate should not create a biomarker observation after a subject’s observed event and then compare it as if it had been measured. The intended prediction target must be stated when event-related observation or dropout affects which measurements are available.

Choosing Summaries and Comparing Replicates

A check is only informative about features captured by its summaries. For each subject with at least two distinct measurement times, one possible slope summary is the least-squares slope of the observed measurements against time. A range summary is the maximum minus the minimum measurement. The minimum and maximum can also be examined separately, since a similar range can arise from different extremes. Slopes and ranges have the biomarker’s units per unit time and the biomarker’s units, respectively.

Within-subject variability needs a precise definition. One useful summary is residual variation around a subject-specific fitted trajectory, rather than variation around that subject’s raw mean. For a linear trajectory fitted to one subject with \(n_i>2\) measurements, define the residual standard deviation as

$$ s_{i,\mathrm{res}}= \sqrt{\frac{\sum_{j=1}^{n_i}(Y_{ij}-\widehat{a}_i-\widehat{c}_i t_{ij})^2}{n_i-2}}, $$

where \(\widehat{a}_i\) and \(\widehat{c}_i\) are the fitted intercept and slope for that subject. This measures scatter around a linear trend; it is not a universal measure of within-subject variability. If the fitted trajectory is nonlinear, or if residuals are autocorrelated or heteroscedastic, the summary and its interpretation need to reflect that structure. In posterior predictive replication, calculate the same summary by the same rule for observed and replicated data.

A statistic \(T\) can summarize one trajectory or a feature across subjects—for example, the median subject-specific slope, the largest subject range, or the median residual standard deviation. For posterior draw \(s\), calculate \(T(Y^{\mathrm{rep},(s)})\) and compare it with \(T(Y)\). An upper-tail posterior predictive probability is estimated by

$$ \widehat{p}_{\mathrm{ppc}} = \frac{1}{B}\sum_{s=1}^{B} I\!\left\{T(Y^{\mathrm{rep},(s)})\geq T(Y)\right\}, $$

where \(B\) is the number of replicated data sets and \(I\{\cdot\}\) equals 1 when the condition is true and 0 otherwise. A value near 0 means the observed summary is larger than nearly all replicated summaries; a value near 1 means it is smaller than nearly all of them. A value near the middle indicates that the observed summary is not unusual relative to these replicates, but it does not establish adequate fit in other respects.

Important interpretation: A posterior predictive probability is a model-checking summary, not a conventional p-value with a uniform null distribution. The observed data contribute to the posterior used to generate the replicates, so observed and replicated summaries are not independent under a null hypothesis. Do not interpret the number as the probability that the model is true.

Worked Example: Checking the Median Biomarker Slope

Suppose a hypothetical study has measurements from 40 subjects over time in months. The observed median subject-specific least-squares slope is \(0.42\) biomarker units per month. The fitted longitudinal model has a specified trajectory form and error distribution; the check uses the observed measurement times and the same rule for calculating slopes in every replicate. These conditions make the observed and replicated summaries comparable.

After drawing 500 posterior parameter and subject-effect sets and generating a replicated marker data set for each, 341 replicated median slopes are at least \(0.42\). Thus,

$$ \widehat{p}_{\mathrm{ppc}} = \frac{341}{500} = 0.682. $$

The observed median slope is not in an extreme upper tail of these replications. This provides no strong evidence, from this summary alone, that the model systematically misses the median slope. It does not show that the slope distribution, individual slopes, curvature, or residual variation are well reproduced. Those features require their own summaries and comparisons.

Worked Trajectory Calculations

Worked Example: Slope, Range, and Residual Variation for One Subject

Consider a hypothetical subject measured at \(t=0,1,2\) years, with biomarker values \(10,12,11\) units. The measurement times are distinct, and a straight line is used solely to define the summary for this example.

The mean time is 1 year and the mean measurement is 11 units. The least-squares slope is

$$ \widehat{c} = \frac{(-1)(10-11)+(0)(12-11)+(1)(11-11)} {(-1)^2+0^2+1^2} = \frac{1+0+0}{2} = 0.500\ \text{units per year}. $$

The fitted line has intercept \(10.5\) units, so its fitted values at years 0, 1, and 2 are \(10.5,11.0,11.5\). The observed range is \(12-10=2\) units. The residuals are \(-0.5,1.0,-0.5\) units, giving residual sum of squares \(0.25+1+0.25=1.50\) squared units. The residual standard deviation for this defined summary is

$$ s_{\mathrm{res}} = \sqrt{\frac{1.50}{3-2}} = 1.225\ \text{units}. $$

This is a very small series, so its fitted residual variation is imprecise; it is an arithmetic illustration, not a reliable subject-level estimate. In a check, the same summaries would be computed for the corresponding replicated series and then assessed across posterior draws. Three measurements also cannot support a detailed assessment of nonlinear trajectory shape.

Worked Example: An Unusually Large Observed Range

In a hypothetical group of four subjects, the observed within-subject ranges are \(2,2,8,\) and \(9\) biomarker units. The statistic is the largest subject range, so \(T(Y)=9\) units. Suppose 200 posterior predictive data sets are generated at the same measurement schedules, and 24 have a largest subject range of at least 9 units. The fitted model and the range calculation are held consistent across observed and replicated data.

$$ \widehat{p}_{\mathrm{ppc}} = \frac{24}{200} = 0.120. $$

Only 12.0% of the replicated data sets reach or exceed the observed maximum range. This is a signal to investigate whether the model’s trajectories or error distribution underproduce large ranges. It is not a formal rejection at a specified significance level. The summary may also be driven by one subject, so it is sensible to inspect the distribution of subject ranges and the associated trajectories rather than relying only on the maximum.

Practical Workflow, Diagnostics, and Alternatives

A defensible check starts by stating the prediction target and the summary before looking at its result. Then use posterior draws that represent the fitted joint model, generate marker values under the longitudinal submodel, and calculate identical summaries for the observed and replicated data. The following sequence makes the comparison explicit.

1
Specify the target.
Decide whether the check is conditional on the observed subjects’ posterior random effects or is for new subjects from the fitted population. State which measurement times and covariates are held fixed.
2
Choose trajectory summaries.
Define slope, range, minimum, maximum, and within-subject variability precisely. Decide whether each summary is subject-level or a group-level aggregate, and how subjects with too few measurements are handled.
3
Generate replicated marker data.
For each posterior draw, generate values from the fitted longitudinal distribution at the stated design points. Preserve the model’s specified error structure, including any modeled heteroscedasticity or serial dependence.
4
Compare distributions and inspect subjects.
Calculate the same summaries for observed and replicated data. Look at their distributions and relevant subject-level trajectories, not only one posterior predictive probability.

Plots of observed summaries against replicated distributions can reveal features obscured by a single tail area. Check slopes at more than one time scale when scientifically relevant, and examine minima and maxima separately as well as ranges. A model could match a median slope while missing the spread of slopes, or match a range while placing its minimum and maximum incorrectly. For variability, compare the distribution across subjects and check whether discrepancies are concentrated at particular times or measurement levels.

The earlier material on longitudinal residual diagnostics provides complementary ways to look for systematic patterns in the observed data. Residual diagnostics focus on deviations from fitted values; posterior predictive checks ask whether whole replicated data sets reproduce selected observed features under parameter uncertainty. Neither replaces the other. A parametric bootstrap can also compare simulated data with observed summaries, but it generally uses a different treatment of parameter uncertainty than posterior predictive simulation. The appropriate comparison depends on the inferential framework and diagnostic question.

Several failures can make a check hard to interpret. If the model’s posterior simulation has not adequately explored its posterior distribution, apparent discrepancies may reflect computation rather than model fit. If observed and replicated summaries use different time grids, different rules for missing measurements, or different slope calculations, the comparison is not like-for-like. Very small numbers of measurements make individual slopes and extrema unstable. A maximum range is especially sensitive to sample size: larger groups have more opportunities to contain an extreme. Interpret it relative to replicates with the same design and group size.

Subject-conditional replications use posterior-informed random effects, so they can reproduce subject-specific patterns more closely than new-subject replications. Consequently, a good conditional check does not establish that the population random-effects distribution is adequate. Conversely, a new-subject check can expose poor population-level predictions but may differ because it draws fresh effects, not because the measurement-error model is wrong. These checks also cannot diagnose features they do not summarize. A model may pass a range check and still miss curvature, multimodality, or a time-dependent variance pattern.

Common pitfall: “The posterior predictive probability is 0.50, so the model fits.” This is not justified: one statistic can look typical while other trajectory features are missed, and posterior predictive probabilities are not calibrated conventional p-values. Correct the reasoning by defining several scientifically relevant summaries, checking their replicated distributions, and inspecting where any discrepancies occur.

Posterior predictive checks are most useful as a structured way to find consequential lack of fit, not as a score that certifies a model. Report what was held fixed, whether effects were conditioned on or redrawn, the summary and its units, the number of simulations, and the observed position in the replicated distribution. A discrepancy should prompt model investigation; it does not by itself identify which model component needs changing.

Check Your Understanding

Answer these questions, then compare with the solutions below.

  1. In a subject-conditional check, what is held fixed about the subjects, and what is newly generated?
  2. An observed summary is exceeded by 45 of 300 replicated summaries. Calculate the upper-tail posterior predictive probability and interpret it.
  3. Why can matching the observed range fail to show that a model reproduces trajectory shape?
  4. Why should the largest range be compared with replications having the same number of subjects and the same measurement design?

Solutions. (1) The observed subjects and, typically, their covariates and measurement times are held fixed; posterior draws of parameters and subject effects inform the generation of new biomarker measurements. (2) The estimate is \(45/300=0.150\). The observed summary is at or above 15.0% of the replicated summaries, so it is not especially extreme in the upper tail by this comparison; this is a diagnostic summary, not a conventional p-value. (3) Different trajectories can have the same maximum minus minimum—for example, they may have different slopes, curvature, or timing of their extremes. (4) The maximum tends to increase as the number of subjects or opportunities for extreme values increases. Holding the design and group size comparable makes the observed and replicated maxima interpretable against the same sampling setup.

Clinical Biostats