Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Residual Patterns For Detecting Trajectory Misspecification

Model Diagnostics · Tutorial 598 of 697

Residual Patterns For Detecting Trajectory Misspecification

Learn to read longitudinal residual patterns as evidence about a fitted biomarker trajectory, distinguish systematic mean misfit from other sources of variation, and investigate suspicious patterns.

Advanced 11 min read

What You'll Learn

  • Define and interpret longitudinal residuals against time and fitted biomarker values.
  • Recognize patterns that may indicate omitted curvature or a misspecified time trend.
  • Assess why apparent residual patterns near trajectory boundaries need special caution.
  • Use residual smooths and subject-level displays without treating repeated observations as independent.
  • Separate evidence about the fitted mean trajectory from other possible sources of residual structure.
  • Apply a diagnostic workflow and explain its limitations.

Why Examine Residual Patterns?

A longitudinal model can produce plausible average trajectories while still getting their shape wrong. A fitted straight line, for example, may systematically underpredict early and late biomarker values and overpredict values in the middle. A single summary of residual size may not reveal this problem; plotting residuals against follow-up time or the fitted biomarker value can expose the pattern.

These plots are diagnostic evidence, not automatic tests of a particular alternative model. In joint models, repeated measurements from the same person are related, and event processes can affect which longitudinal measurements are observed. A pattern should therefore prompt a model check in context, not a causal conclusion or an unqualified claim that the trajectory is wrong.

Definition: For subject \(i\) at observed time \(t_{ij}\), let \(y_{ij}\) be the biomarker measurement and let \(\widehat m_{ij}\) be the fitted value from the longitudinal submodel. The raw residual is \(r_{ij}=y_{ij}-\widehat m_{ij}\). A residual-versus-time plot places \(r_{ij}\) against \(t_{ij}\); a residual-versus-fitted plot places it against \(\widehat m_{ij}\). The fitted value and residual must be defined using the same prediction target—for example, a conditional fitted value for a subject-specific trajectory.

The earlier material on conditional and marginal residuals distinguishes residuals formed from subject-specific fitted trajectories from those formed using the population-level mean. That choice matters here. Conditional residuals can help examine the trajectory after accounting for estimated subject effects; marginal residuals also reflect between-subject variation. Empirical estimates of subject effects are uncertain, so conditional residual patterns are not a perfect view of each person’s true trajectory.

What a Pattern Says About the Mean Trajectory

If the longitudinal mean structure is adequate, residuals should fluctuate around zero without a persistent systematic trend across time or fitted values. This does not mean every point must be close to zero, nor that the points are independent. Random scatter can be substantial, especially when measurements are noisy.

A smooth curve through residuals helps summarize the conditional mean pattern. A curve that stays near zero is compatible with an adequate mean trajectory, while a sustained departure from zero suggests that the fitted mean may leave some systematic structure unexplained. In a residual-versus-time plot, a U-shape or inverted U-shape can indicate omitted curvature. A roughly monotone trend can suggest an incorrect time trend, such as a missing time effect or an unsuitable time scale. A pattern against fitted values can reveal that the model’s errors change systematically across the biomarker range; curvature there may also indicate that the functional form for the mean is inadequate.

A useful justification follows from the meaning of a residual. Suppose the true conditional mean at time \(t\) is \(m(t)\), while the fitted mean is \(\widehat m(t)\). Ignoring estimation error for the moment, the conditional expected residual is

$$ E\{Y-\widehat m(t)\mid t\}=m(t)-\widehat m(t). $$

Thus, a systematic gap between the true and fitted mean appears as a nonzero conditional mean of the residuals. In an ordinary least-squares fit with an intercept, residuals sum to zero overall and are orthogonal to included predictors in the fitting sample. Those global constraints do not require the residual mean to be zero at every time or every fitted value: a curve can rise and fall while its total sum remains zero.

In joint models, this argument is a guide to interpretation, not a guarantee that a visual pattern has one cause. Residuals use estimated model parameters and, for conditional residuals, estimated subject effects. Also, measurements are repeated within subjects. A smooth plotted through all observations may look precise simply because some subjects contribute many measurements. Consider the number and timing of subjects’ observations, and where possible compare the pooled plot with subject-specific displays or summaries.

Worked Example: Detecting Omitted Curvature

Hypothetical data. For one illustrative trajectory, measurements are taken at \(t=0,1,2,3,4\) months, with biomarker values \(y=10,11,14,19,26\) units. A straight-line mean is fitted by least squares. Calculate the fitted line and residuals, then interpret their pattern.

The mean time is \(\bar t=2\), and the mean biomarker value is \(\bar y=16\). The least-squares slope is

$$ \widehat\beta_1= \frac{\sum_j(t_j-\bar t)(y_j-\bar y)} {\sum_j(t_j-\bar t)^2} = \frac{40}{10}=4\text{ units per month}. $$

The intercept is \(\widehat\beta_0=\bar y-\widehat\beta_1\bar t=16-(4)(2)=8\) units. Thus, \(\widehat m(t)=8+4t\), giving fitted values \(8,12,16,20,24\) units. Subtracting fitted from observed values gives residuals \(2,-1,-2,-1,2\) units.

The residuals are positive at the two ends and negative in the middle, suggesting a U-shaped pattern. This is consistent with the straight-line model failing to capture upward curvature. It is not proof that a quadratic trajectory is the correct model: with only five measurements, the pattern could also reflect noise or other structure. A next step is to examine the plot alongside subject-level trajectories and compare a scientifically plausible curved mean structure.

Distinguishing Time Trends and Fitted-Value Patterns

The two plot axes answer related but different questions. Time is the natural axis for asking whether the trajectory evolves incorrectly over follow-up. Fitted biomarker values ask whether residuals tend to be positive or negative in particular regions of the predicted biomarker range. In a monotone trajectory these axes may be strongly related, so seeing a similar curve in both plots does not provide two independent pieces of evidence.

Worked Example: A Missing Time Trend

Hypothetical data. Suppose a model specifies a constant conditional biomarker mean of 16 units over time for an illustrative subject. At times \(0,1,2,3,4\) months, the observed values are \(12,14,16,18,20\) units. Calculate and interpret the residuals under the stated model.

Because the fitted value is 16 units at every time, the residuals are \(12-16=-4\), \(14-16=-2\), \(16-16=0\), \(18-16=2\), and \(20-16=4\) units. These values rise steadily with time. The pattern indicates that a constant mean does not represent the observed time trend well for these data. A model allowing a time effect could be considered, if that change is compatible with the scientific question and the wider data.

The arithmetic illustrates a diagnostic pattern, not a complete joint-model analysis. In practice, subject-specific fitted values and residuals would depend on the fitted longitudinal submodel, including any random effects. A pooled upward pattern could reflect a population time trend, differences between subjects, or the way subjects contribute observations; it should not automatically be attributed to one individual trajectory.

A fitted-value plot is especially helpful when misspecification is not simply a function of time. For example, residuals that are mostly negative at low fitted values and positive at high fitted values indicate underprediction at one end and overprediction at the other. The same sign-pattern logic applies: residuals above zero mean the observed biomarker exceeds the fitted value, while residuals below zero mean the fitted value exceeds the observation.

Boundary Patterns and Sparse Support

The beginning and end of the observed time range deserve separate scrutiny. Flexible trajectory models, including spline-based models, are often less well supported near boundaries because there are fewer nearby observations on one or both sides. A residual pattern concentrated at the earliest or latest times may reflect an inadequate boundary fit, sparse data, influential observations, or an unsuitable time specification. It does not by itself establish which explanation is responsible.

Boundary evidence is particularly fragile when only a small number of subjects contribute measurements near the edge, or when observation times are shaped by clinical events. In a joint longitudinal and event-time analysis, later biomarker values may be unavailable after an event. A plot of observed residuals at late times therefore describes the available measurements, not necessarily the trajectory that would have been observed for all subjects had follow-up continued. Do not extrapolate a boundary pattern beyond the observed support on the strength of the plot alone.

Worked Example: Investigating an Early-Boundary Pattern

Hypothetical data. Residuals near the beginning of follow-up are \(1.2,0.8,0.9\) units, while three residuals in a well-supported interior region are \(-0.2,0.1,-0.1\) units. Calculate the two averages and explain what they do—and do not—show.

The early-boundary average is \((1.2+0.8+0.9)/3=2.9/3=0.967\) units. The interior average is \((-0.2+0.1-0.1)/3=-0.2/3=-0.067\) units. The contrast is about \(1.03\) units, suggesting that the fitted trajectory may underpredict measurements near the early boundary relative to the interior.

This small illustration does not establish a general boundary effect: each average uses only three residuals, and the measurements may come from the same subjects. Check how many subjects contribute at the boundary, inspect individual trajectories, and assess sensitivity to reasonable alternatives for the time structure. If the pattern disappears when a small number of observations is examined individually, it may be driven by those observations rather than broad systematic misspecification.

A Practical Diagnostic Sequence

Interpretation is stronger when the plot is connected to the model’s prediction target, observed data support, and repeated-measures structure. A disciplined sequence helps keep visual clues from being treated as conclusions.

1
Define the residual and target.
State whether fitted values are conditional or marginal, and check that the plotted residual is observed minus fitted.
2
Plot against time and fitted value.
Include a zero reference line, make the units and time scale clear, and consider a smooth as a descriptive aid rather than a formal test.
3
Check who and when contribute.
Look for sparse regions, boundary concentrations, and subjects with many observations. Compare with subject-level displays where useful.
4
Connect the pattern to a plausible model change.
Consider whether a time effect, curvature, or another scientifically defensible mean structure could address the pattern; then refit and reassess.

Residual pattern plots are mainly descriptive. Their visual smooths do not automatically come with valid uncertainty bands, especially if repeated measurements are treated as independent. If formal inference about a pattern is needed, its uncertainty must account for the dependence and model-fitting process. A diagnostic refit should also be compared on the same target and observed support; otherwise, apparent improvement may reflect a changed set of observations rather than a better trajectory.

Residual structure can have more than one source. A trend in the residual mean concerns the fitted trajectory, whereas serial dependence among residuals concerns their association across measurement times; the earlier material on residual autocorrelation addresses the latter. Likewise, a changing residual spread is not the same as a changing residual mean. Keep these questions separate when reading a plot, rather than assigning every visible feature to trajectory shape.

Common Pitfalls and Limitations

  • Calling any curved scatter a misspecified trajectory. A few extreme observations can bend a smooth. Check the observations, subject contributions, and support before changing the mean structure.
  • Treating all plotted measurements as independent. Many residuals from one subject do not provide the same evidence as the same number of residuals from different subjects. Use subject-level context when interpreting pooled patterns.
  • Reading a boundary pattern as evidence beyond the data. Sparse observations near the end of follow-up cannot establish how trajectories behave outside the observed range.
  • Confusing residual mean and residual spread. A systematic upward or downward smooth concerns average prediction error. A change in vertical scatter concerns variability and requires a different diagnostic interpretation.
  • Assuming a better-looking fit is automatically better. More flexible trajectories can follow noise. A plausible time structure, adequate support, and careful reassessment are needed; visual fit alone is not a model-selection rule.

These plots are useful because they show where a fitted biomarker trajectory tends to miss, not merely how large residuals are overall. They have limits: the residuals are estimated, observations are clustered, and event-related observation patterns can constrain what the data reveal. Read a pattern as a reason to investigate, and describe its location, direction, and supporting data before proposing a change.

Check Your Understanding

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

  1. If residuals are mostly positive at early times and negative at later times, what does the sign pattern say about fitted versus observed biomarker values?
  2. Why can a residual smooth near the end of follow-up be unstable even when it looks pronounced?
  3. A residual-versus-fitted plot has a U-shape. What is one possible implication, and why is it not a definitive diagnosis?
  4. Why should a pooled residual plot be interpreted with subject-level context?

Solutions. (1) Positive residuals mean observed values exceed fitted values, so the model tends to underpredict early; negative residuals mean it tends to overpredict later. The pattern may indicate an incorrect time trend, but other features of the data and model should be checked. (2) Few subjects or measurements may support that part of the time range, so a small number of observations can drive the smooth; the pattern also cannot establish behavior beyond observed follow-up. (3) A U-shape may indicate systematic underprediction at low and high fitted values and overprediction in the middle, consistent with omitted curvature. Noise, influential observations, or dependence can also produce an apparent shape, so inspect the data and model context. (4) Measurements from the same subject are related, and subjects contribute different numbers and timings of measurements. A pooled pattern can be dominated by a subset of subjects and should not be read as independent evidence at every point.

Clinical Biostats