Why a Flexible Trajectory Needs Careful Checking
A spline can represent gradual changes in a longitudinal marker without imposing one rigid curve over the full follow-up period. But flexibility is not automatically evidence that every bend in the fitted trajectory is real. Near the beginning or end of observed follow-up, data are often sparse and the fitted curve can be sensitive to a few observations. Within the observed range, an overly flexible spline can also turn random variation into rapid local ups and downs.
These concerns matter in joint models because the longitudinal trajectory is part of a model used alongside the event process. A poorly supported bend can affect how the marker is summarized and, in turn, how its relationship with event risk is represented. The aim here is not to remove all curvature. It is to check whether the fitted shape is stable, sufficiently precise, and useful for predicting data not used to fit it.
Model and Assumptions for Shape Diagnostics
Let \(Y_{ij}\) be the longitudinal response for subject \(i\) at time \(t_{ij}\), and let \(b_i\) denote that subject’s random effects. For a generalized longitudinal submodel, write
Here \(g\) is the response link, \(x_i\) contains fixed covariates, \(B(t)\) is a vector of spline basis functions, \(\gamma\) is its coefficient vector, and \(z_{ij}^\top b_i\) represents subject-specific effects. For example, a binary marker may use the logit link, while a count marker may use the log link. The fitted trajectory on the response scale is obtained by applying \(g^{-1}\) to the linear predictor; the shape on the response scale need not look like the shape on the link scale.
Shape diagnostics are meaningful only relative to the model and the observed time range. They assume that the response distribution and link are reasonable for the marker, that the spline basis and its boundary rules are known, and that uncertainty accounts for the fitted model’s coefficient covariance. In a joint model, interpretation also depends on how random effects and the event process enter the likelihood. A plot of the fixed spline component alone is not the same as a subject-specific fitted trajectory.
Begin by plotting the fitted trajectory over the times actually observed, marking the data density or measurement times. Inspect the link-scale curve as well as the response-scale curve, and identify whether a plotted line is population-level or conditional on particular random effects. Avoid interpreting a curve far outside the observed time range as data-supported. Even a spline with controlled tails cannot create empirical information where follow-up is absent.
Curvature and Its Uncertainty
For a fixed covariate profile and reference random effects, let the time-varying part of the linear predictor be \(\eta(t)=B(t)^\top\gamma\). Its first and second derivatives are
The second derivative describes curvature on the link scale. If \(\widehat{\gamma}\) has estimated covariance matrix \(\widehat{\Sigma}_{\gamma}\), then the fitted linear predictor at a fixed time has estimated variance
This follows from the variance rule for a linear combination: for a coefficient vector with covariance \(\widehat{\Sigma}_{\gamma}\), the variance of \(B(t)^\top\widehat{\gamma}\) is \(B(t)^\top\widehat{\Sigma}_{\gamma}B(t)\). Thus, the pointwise standard error is the square root of this expression. A pointwise 95% Wald interval on the link scale is \(\hat{\eta}(t)\pm1.96\,SE\{\hat{\eta}(t)\}\); transforming both endpoints by \(g^{-1}\) gives a corresponding interval on the response scale.
A pointwise band describes uncertainty at each selected time separately; it is not a 95% simultaneous band for the entire curve. Moreover, coefficient intervals for curvature or visual uncertainty bands do not test whether the whole shape is correct. They are evidence to consider alongside the data support, model fit, and validation.
Worked Example: A Sharp Bend at the Follow-Up Boundary
Suppose a hypothetical binary marker is observed mostly between months 2 and 10, with only a few observations near month 12. For a reference covariate profile, a flexible logit spline estimates \(\hat{\eta}(10)=0.2\), \(\hat{\eta}(11)=1.0\), and \(\hat{\eta}(12)=2.6\). The successive changes are \(1.0-0.2=0.8\) and \(2.6-1.0=1.6\) log-odds units per month. The steepening at the boundary is a reason to investigate, not by itself proof of overfitting.
At month 12, suppose \(SE\{\hat{\eta}(12)\}=0.95\). The pointwise interval on the logit scale is
Applying the inverse-logit function \(p=1/(1+\exp(-\eta))\), the fitted probability is \(1/(1+\exp(-2.6))\approx0.931\). Transforming the interval endpoints gives approximately \([0.676,\ 0.989]\). These are pointwise Wald limits for the probability at month 12 under the stated model and reference profile; they do not express a probability that the unknown parameter lies in this particular interval.
The widening uncertainty, sparse boundary data, and sharp increase together make the end shape questionable. A sensible follow-up is to compare it with a less flexible specification and assess predictions on held-out subjects. The interval alone cannot establish that the bend is an artifact.
Detecting Local Oscillation
Local oscillation is often easiest to notice by inspecting changes over nearby times on the link scale. A sequence of alternating increases and decreases over short intervals may reflect noise being followed too closely, especially when there are few observations in those intervals. But a genuine transient response can also change direction. The diagnostic question is whether the pattern is well supported and reproducible, not whether the curve is perfectly smooth.
Check the observation times, fitted values, and uncertainty together. A bend where there are no nearby observations is less convincing than one supported by repeated measurements across subjects. Compare fitted shapes under a modest reduction in spline flexibility, keeping the response distribution, link, covariates, and other modeling choices fixed where possible. If a small change in basis or knot placement substantially changes a local wiggle, that sensitivity is itself a warning. It is not an automatic instruction to select the smoother curve.
Worked Example: Alternating Changes in a Count Trajectory
Consider a hypothetical count marker fitted with a log link. At four consecutive, equally spaced interior times, a flexible spline gives linear predictors \(0.10,\ 0.28,\ 0.14,\ 0.32\). The changes are \(+0.18,\ -0.14,\ +0.18\) log-mean units. The implied means are
Thus the fitted mean rises, falls, and rises again over equally spaced times. Suppose the pointwise standard error at each time is about \(0.18\) on the log scale. The changes are not each direct evidence of a real reversal: their uncertainty is correlated across times, and pointwise intervals do not provide a test of the entire sequence. The next checks are whether observations support each turn, whether the pattern persists under a less flexible basis, and whether the flexible fit predicts held-out subjects better. The numbers raise a diagnostic flag; they do not establish that the trajectory is wrong.
Held-Out Predictions and Model Comparison
A direct way to assess whether additional spline flexibility is useful is to compare predictions for data excluded from fitting. Split by subject, not by individual measurement: placing some measurements from one subject in the training set and others in the test set can make validation optimistic because the fitted random effects have already used information from that subject. Fit each candidate model using the training subjects, then predict the held-out measurements without using their longitudinal outcomes to estimate their random effects. The resulting comparison assesses prediction for new subjects under the specified prediction target; it is not a dynamic prediction that updates from a held-out patient’s history.
Use a score suitable for the response. For binary outcomes, the Brier score is the average squared difference between the observed value \(y\in\{0,1\}\) and its predicted probability \(\hat p\): \((y-\hat p)^2\). For counts or ordinal responses, use a score appropriate to the fitted predictive distribution, such as a log score when the probabilities are available. Compare scores on the same held-out observations. Lower average loss is better for these scores, but one split can be noisy; repeated subject-level splits or cross-validation provide a more stable comparison when feasible.
Worked Example: Comparing Binary Held-Out Predictions
Suppose two hypothetical models predict four held-out binary outcomes, which are \(1,0,1,0\). A flexible spline gives probabilities \(0.80,0.70,0.65,0.30\); a smoother spline gives \(0.70,0.30,0.60,0.40\). For the flexible model, the four squared errors are
Its mean Brier score is \((0.0400+0.4900+0.1225+0.0900)/4=0.1856\). For the smoother model, the errors are \(0.0900,\ 0.0900,\ 0.1600,\ 0.1600\), giving a mean of \(0.1250\). On these four held-out observations, the smoother model has the lower Brier score. This small comparison is not conclusive by itself, but it gives no predictive justification for the extra flexibility in this split.
Choosing a Response to a Diagnostic Warning
The main alternatives to an unstable flexible spline are not interchangeable fixes. A lower-dimensional parametric trajectory imposes a stronger shape assumption and can be more stable, but may miss real changes. A natural cubic spline constrains the tails to be linear beyond its boundary knots, reducing tail curvature by construction; that constraint is not evidence that the data support a linear tail. A penalized spline discourages excessive roughness while allowing the data to determine some of the smoothness, but its result still depends on the penalty and its estimation. A simpler basis, alternative boundary rule, or penalized fit can therefore be useful sensitivity analyses.
For a warning near the boundary, first check how much data support the end of follow-up and whether the plotted region extends beyond it. Then compare the boundary shape and uncertainty under a reasonable alternative specification. For apparent interior oscillation, inspect local data support and sensitivity to flexibility. In either case, consider held-out performance and retain the more flexible curve only when its added structure is credible and useful.
Mark sparse boundary regions and short intervals with rapid changes; state whether the curve is on the link or response scale and whether it is population-level or subject-specific.
Inspect pointwise uncertainty and the measurements contributing information in that time region. Do not interpret a band as a simultaneous guarantee for the whole curve.
Compare defensible alternative smoothness or boundary specifications, then evaluate subject-level held-out predictions using a response-appropriate score.
Common failure modes include treating every wiggle as false, treating a smooth-looking line as proof of reliability, and choosing a model solely because it has the smallest training error. Another mistake is to let a boundary constraint conceal extrapolation: a linear tail imposed by a natural spline remains an assumption outside the data, not a discovery. Finally, held-out scores assess predictive performance for the chosen target and split; they do not prove that a fitted curve is the true biological trajectory.
Check Your Understanding
Answer each question, then compare with the brief solutions.
- Why can a spline’s fitted curvature be especially unstable near the end of follow-up?
- A pointwise 95% interval is computed separately at each of 20 times. Does it guarantee 95% coverage of the entire trajectory?
- Why should held-out validation generally split by subject rather than by measurement?
- A more flexible binary spline has a lower training Brier score but a higher held-out Brier score. Which result is more relevant to prediction for new subjects?
- What does a linear tail from a natural cubic spline establish about behavior beyond observed follow-up?
Solutions. (1) There may be few observations near that boundary, so estimates can be sensitive to a small amount of data and to the spline specification. (2) No. Pointwise coverage applies separately at each time; it does not provide a 95% simultaneous band for the whole curve. (3) Measurements from the same subject share random effects and other information; splitting them across sets can leak subject-specific information into validation. (4) The held-out score is more relevant to prediction for new subjects, though a single split may be noisy. (5) It establishes that the chosen spline specification imposes a linear tail; it does not establish that the true trajectory is linear there.