Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Checking Time-Varying Hazard Misfit With Residuals

Model Diagnostics · Tutorial 607 of 697

Checking Time-Varying Hazard Misfit With Residuals

Use time-ordered and risk-set residual summaries to find hazard departures that may cancel in an overall goodness-of-fit statistic.

Advanced 10 min read

What You'll Learn

  • Define survival-component residual increments and cumulative residual processes over follow-up.
  • Calculate observed-minus-expected event counts in time intervals and risk sets.
  • Interpret residual direction and distinguish local patterns from overall cancellation.
  • Recognize assumptions involving censoring, risk-set construction, and fitted joint-model hazards.
  • Identify when uncertainty from parameter fitting and latent effects affects diagnostic conclusions.

Why Examine Residuals Over Time?

An overall survival goodness-of-fit summary can conceal where a fitted hazard departs from observed event experience. For example, the model may predict too few events early and too many later. Positive and negative discrepancies can then offset, leaving a small overall difference even though the timing of events is poorly represented. A time-ordered residual display keeps those discrepancies visible.

In a joint model, the event hazard may depend on a subject’s longitudinal trajectory, latent random effects, and other covariates. The diagnostic question here is narrower: does the fitted survival component reproduce event occurrence over follow-up and among the subjects actually at risk? Residual summaries can reveal systematic time-localized patterns, but they do not by themselves identify which part of the joint model caused a departure.

Definition: For subject \(i\), let \(Y_i\) be the observed follow-up time, the minimum of the event time and censoring time, and let \(\delta_i=1\) if the event was observed and \(0\) if the observation was censored. Define \(N_i(t)=I(Y_i\leq t,\delta_i=1)\) and \(R_i(t)=I(Y_i\geq t)\), the event-counting and at-risk processes. If \(\widehat{\lambda}_i(t)\) is the fitted event hazard while subject \(i\) is at risk, the fitted cumulative hazard through \(t\) is \(\widehat{\Lambda}_i(t)=\int_0^t\widehat{\lambda}_i(s)\,ds\). The subject’s survival-component martingale residual through \(t\) is \(M_i(t)=N_i(t)-\int_0^tR_i(s)\widehat{\lambda}_i(s)\,ds\).

The first term records whether an event has occurred by \(t\); the integral is the model’s accumulated expected event intensity while the subject remained at risk. A positive residual means observed event accumulation exceeds fitted accumulation up to that time, while a negative residual means it falls short. This is a signed discrepancy, not a probability or an individual-level measure of model truth.

In a joint model, \(\widehat{\lambda}_i(t)\) must be based on the survival component and the longitudinal information available for the diagnostic target. A hazard conditional on a specified random effect is not the same object as a hazard averaged over uncertainty about that random effect. The analyst should state which fitted intensity is used. For a diagnostic intended to describe the observed-data event process, the relevant intensity averages over latent quantities conditional on the observed history available at time \(t\); using a plug-in estimate of each subject’s random effect is a simpler approximation and should be identified as such.

From Subject Residuals to Time-Ordered Summaries

Under a correctly specified event model, the event process has conditional intensity \(R_i(t)\lambda_i(t)\): over a short interval of length \(dt\), the conditional expected event increment is approximately \(R_i(t)\lambda_i(t)dt\). Thus the model’s expected event increment is the fitted hazard multiplied by time at risk. Subtracting that increment from the observed event increment gives a residual increment:

$$ d\widehat{M}_i(t)=dN_i(t)-R_i(t)\widehat{\lambda}_i(t)\,dt. $$

Summing across subjects and accumulating from the start of follow-up gives the risk-set residual process:

$$ \widehat{M}(t)=\sum_{i=1}^{n}\left\{N_i(t)-\int_0^t R_i(s)\widehat{\lambda}_i(s)\,ds\right\}. $$

The justification is direct: if the fitted intensity equals the true conditional intensity, then the conditional expectation of each event increment equals the hazard contribution subtracted from it. In the ideal known-parameter model, the expected residual increment is therefore zero. Cumulative residuals fluctuate around zero, but they are not expected to equal zero at every time. Estimation, dependence induced by shared model parameters, and latent-effect uncertainty also affect their variability in fitted joint models.

A useful complementary summary divides follow-up into intervals \(I_k=(a_k,b_k]\). Let \(O_k\) be the observed number of events in that interval and \(E_k\) the fitted expected number:

$$ O_k=\sum_i\int_{I_k}dN_i(t),\qquad E_k=\sum_i\int_{I_k}R_i(t)\widehat{\lambda}_i(t)\,dt,\qquad D_k=O_k-E_k. $$

Plotting \(D_k\) against interval or follow-up time can make a local excess or deficit easier to see than a single cumulative curve. A rough scale for a standardized interval discrepancy is \(D_k/\sqrt{E_k}\), motivated by a Poisson count with variance approximately its mean. This is only a descriptive approximation: risk sets overlap across intervals, fitted parameters are estimated, and joint-model subjects may share latent or parameter uncertainty. Formal reference bands should account for the fitting procedure and dependence rather than treating these rough standardized values as independent standard normal statistics.

Worked Example: Interval Residuals Reveal Cancellation

Suppose a hypothetical fitted survival component predicts \(E_1=4.2\) events during follow-up interval \((0,2]\) and \(E_2=5.8\) during \((2,4]\). The corresponding observed event counts are \(O_1=7\) and \(O_2=3\). Compute and interpret the interval discrepancies.

For the first interval, \(D_1=O_1-E_1=7-4.2=2.8\). The model predicts fewer events than were observed in this interval. The rough standardized discrepancy is \(2.8/\sqrt{4.2}=2.8/2.049=1.366\).

For the second interval, \(D_2=3-5.8=-2.8\), so the model predicts more events than were observed. Its rough standardized discrepancy is \(-2.8/\sqrt{5.8}=-2.8/2.408=-1.163\).

Across both intervals, the total observed count is \(7+3=10\), and the total expected count is \(4.2+5.8=10\). The overall discrepancy is \(10-10=0\), although the interval summaries show a substantial early excess followed by a later deficit. The rough standardized values are descriptive, not calibrated tests; the pattern motivates closer investigation rather than proving misspecification.

Reading Cumulative and Risk-Set Patterns

A cumulative residual curve adds interval discrepancies over time. A sustained upward movement indicates that observed events are accumulating faster than predicted over that period; a sustained downward movement indicates slower accumulation. A rise followed by a fall can return the curve near zero, so its final value alone is not an adequate time-varying diagnostic. Look for persistent departures, changes in slope, and reversals that line up with follow-up time or changes in the composition of the risk set.

Risk-set summaries add a second view. At each interval, the risk set consists of subjects still under observation and event-free at the relevant time. Events and expected counts should be compared among those subjects, not among the original cohort without regard to when each person left follow-up. One can group subjects by fitted risk at the start of an interval, or by a clearly defined covariate stratum, and calculate observed and expected events within each group. For a dynamic joint model, the risk grouping should use only information available at the time defining the group; using future biomarker measurements to classify earlier risk sets can create misleading comparisons.

Worked Example: Subject-Level Residuals at an Event and a Censoring Time

For illustration, suppose the fitted hazard is constant at \(0.20\) per year for two hypothetical subjects over their observed follow-up. Subject A has an event at \(3.5\) years. Subject B is censored at \(3.5\) years. Calculate each subject’s residual at the end of observed follow-up.

For both subjects, the fitted cumulative hazard is \(\widehat{\Lambda}(3.5)=0.20\times3.5=0.70\). Subject A has one observed event, so \(M_A(3.5)=1-0.70=0.30\). The observed event contribution exceeds the fitted cumulative hazard by \(0.30\).

Subject B has no observed event by censoring, so \(M_B(3.5)=0-0.70=-0.70\). This records the \(0.70\) units of fitted cumulative hazard accumulated while B was observed and event-free; it does not mean that B could not have an event after censoring.

The two residuals answer a subject-level accounting question. To assess a time-localized pattern, they must be considered with the event and expected-hazard increments over time and across the risk sets. A single final residual per subject does not show when the discrepancy developed.

Worked Example: Comparing Observed and Expected Events Across Risk Sets

Consider a hypothetical analysis that classifies subjects as lower- or higher-fitted-risk at the start of each interval. Expected counts are obtained by summing fitted hazard contributions over the subjects at risk within each group. The table gives the observed counts and the corresponding fitted expectations.

Follow-up intervalRisk groupObserved \(O\)Expected \(E\)Difference \(O-E\)
EarlyHigher fitted risk963
EarlyLower fitted risk25-3
LateHigher fitted risk34-1
LateLower fitted risk431

In the early interval, the higher-risk group has \(9-6=3\) more events than expected, while the lower-risk group has \(2-5=-3\) fewer. In the late interval, the corresponding differences are \(3-4=-1\) and \(4-3=1\). Each interval’s discrepancies sum to zero, as do the discrepancies across both intervals. Yet the group-specific pattern changes over time: early events are concentrated above expectation in the higher-risk group, whereas later differences point in the opposite direction.

These arithmetic summaries flag a pattern for investigation; they do not establish its cause. The groups must be defined using the risk set at the relevant time, and the expectations must be calculated from the fitted hazards over the actual at-risk time. A group defined once using information from the entire follow-up would not answer the same question.

Assumptions, Diagnostics, and Alternatives

Interpreting these plots requires a valid event-time data structure and a meaningful fitted intensity. In particular, event times and censoring indicators must be correctly recorded; subjects must enter and leave risk sets at the correct times; and censoring must be noninformative conditional on the information represented in the model, or otherwise be handled by the analysis. If the event of interest is subject to competing events, the diagnostic must use the appropriate event-type-specific process and risk-set definition rather than treating competing events as ordinary independent censoring without justification.

The fitted hazard also needs to reflect the intended joint-model conditioning. If the hazard depends on the longitudinal trajectory or latent effects, a time pattern may arise because the hazard’s time dependence is misspecified, because the longitudinal information or association structure is misspecified, or because the fitted latent-effect treatment is inadequate. This diagnostic localizes a survival-component discrepancy; it does not isolate its source. Parameter fitting can make residuals appear more centered than they would be under fixed, known parameters, and naive variability calculations may understate uncertainty.

Useful displays include cumulative residuals over follow-up, interval observed-minus-expected counts, and observed-versus-expected summaries across time-specific risk groups. Inspect the underlying counts and expected exposures alongside any standardized display. Sparse late risk sets can produce volatile summaries; wide or erratic changes driven by very few subjects should not be read as a stable time trend. A pattern that changes substantially when interval boundaries change may also be an artifact of coarse grouping.

These summaries complement rather than replace other survival diagnostics. Subject-level martingale residuals compress each subject’s event history into a signed discrepancy, while deviance residuals rescale subject-level discrepancies for another view of their distribution. Cox-Snell residuals and event-time probability integral transform residuals examine different aspects of fitted survival behavior. None of those single summaries necessarily preserves the sequence of event and expected-hazard increments that reveals local time patterns. Conversely, a time-ordered plot can be noisy and does not provide a calibrated test merely because it is visually suggestive.

A practical reading sequence is to locate intervals or risk groups with repeated positive or negative discrepancies, check their event counts and exposure, and then ask whether the pattern is plausibly related to follow-up time, risk-set composition, or the joint-model information used to construct fitted hazards. Treat a plot as diagnostic evidence, not as proof of a particular mechanism. Formal uncertainty assessment must reflect that the model was estimated and that the same subjects contribute to multiple summaries.

Common pitfall: “The total observed count equals the total expected count, so the fitted hazard is adequate.” This reasoning discards when and among whom events occurred. Early excesses and late deficits, or opposing discrepancies across risk groups, can cancel exactly in the total. Inspect time-ordered and risk-set-specific summaries before drawing an overall conclusion.

Check Your Understanding

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

  1. An interval has 8 observed events and 5.5 expected events. What is the residual discrepancy, and what does its sign indicate?
  2. Two successive intervals have discrepancies \(+4\) and \(-4\). Why can their total of zero conceal a useful diagnostic signal?
  3. In one hypothetical interval, a group has \(O=6\) observed events and \(E=9\) expected events. Compute its rough standardized discrepancy using \(D/\sqrt{E}\), and state a limitation of that value.
  4. Why should risk groups for a time-specific comparison be defined using information available at the start of the interval?
  5. What does a positive subject-level martingale residual at observed follow-up mean, and what does it not mean?

Solutions. (1) \(D=8-5.5=2.5\). The positive sign means observed event accumulation exceeds the fitted expectation in that interval. (2) The first interval has an excess and the second a deficit; the net can be zero even though the model’s timing is poorly represented. (3) \(D=6-9=-3\), so \(D/\sqrt{E}=-3/\sqrt{9}=-1\). This is a rough descriptive scale, not a calibrated test; it ignores fitting uncertainty and dependence. (4) Otherwise future information can determine earlier group membership, changing the comparison and potentially introducing misleading patterns. (5) It means the observed event contribution through that time exceeds fitted cumulative hazard. It is not a probability, a causal statement, or proof that the subject’s individual hazard is misspecified.

Clinical Biostats