Tutorials › Joint Modeling of Longitudinal and Time-to-Event Data › Martingale Residuals For The Event Component

Model Diagnostics · Tutorial 602 of 697

Martingale Residuals For The Event Component

Calculate martingale residuals from fitted event hazards and interpret their distribution and covariate patterns as diagnostics of survival-component fit.

Advanced 11 min read

What You'll Learn

  • Define the observed follow-up time, event indicator, and fitted cumulative hazard used in the residual.
  • Derive the martingale residual from the event-counting process and its hazard compensator.
  • Calculate residuals for event and censored subjects using constant or time-varying fitted hazards.
  • Explain why martingale residuals are skewed and why their mean is more informative than a normality check.
  • Use covariate patterns to identify possible event-hazard misspecification while accounting for sampling variation.
  • Distinguish event-component residual evidence from longitudinal-model diagnostics and other survival diagnostics.

Why Diagnose the Event Component?

A joint model can describe repeated measurements well and still represent the event process poorly. For example, its longitudinal trajectories may be plausible while the fitted hazard systematically underestimates events among people with a particular covariate value. Event-component martingale residuals compare each subject’s observed event contribution with the amount expected from that subject’s fitted hazard over the time they were observed.

These residuals are useful for locating possible lack of fit, not for proving that a model is correct or identifying a unique replacement. Their interpretation depends on the fitted event hazard, the censoring process, and the way latent subject effects enter the hazard. A pattern is evidence to investigate, not a causal conclusion.

Definition and Assumptions

For subject \(i\), let \(T_i\) be the event time and \(C_i\) the right-censoring time. The observed follow-up time is \(U_i=\min(T_i,C_i)\), and the event indicator is \(\Delta_i=I(T_i\le C_i)\), where \(\Delta_i=1\) means the event was observed. Censoring is not counted as an event.

Write \(b_i\) for the subject’s latent random effects, \(w_i\) for event-model covariates, and \(m_i(t;b_i)\) for the latent longitudinal marker value that enters the event model. One common joint-model event hazard is

$$ \lambda_i(t\mid b_i,w_i)=\lambda_0(t)\exp\{\gamma^\mathsf{T}w_i+\alpha m_i(t;b_i)\}. $$

Here \(\lambda_0(t)\) is the baseline hazard, \(\gamma\) is the vector of covariate coefficients, and \(\alpha\) is the association parameter for the marker. This is an example, not a requirement: the residual definition applies to other specified event hazards as well. The hazard has units of inverse time, so its integral over time is dimensionless.

Definition: The event-component martingale residual for subject \(i\) is the observed event indicator minus the fitted cumulative event hazard up to that subject’s observed follow-up time:
$$ \widehat r_{Mi} = \Delta_i-\widehat H_i(U_i), \qquad \widehat H_i(U_i) = \int_0^{U_i}\widehat\lambda_i(t)\,dt. $$
The fitted hazard \(\widehat\lambda_i(t)\) must be the event hazard under the fitted model, evaluated using the model’s specified covariates and latent-trajectory treatment.

This definition presumes a correctly specified conditional event intensity and a censoring mechanism that is noninformative for the event process, at least conditional on the variables and latent effects included in the model. The hazard must be integrable over observed follow-up. In practice, parameters and latent effects are estimated, so the computed residuals are diagnostics based on fitted quantities rather than exact martingales with known parameters.

In a joint model with latent effects, state how the fitted hazard was obtained. For example, it may be evaluated using fitted subject-specific random effects, or it may be based on a model-defined marginal calculation. These are not automatically interchangeable: averaging conditional hazards and then integrating need not give the same quantity as using a conditional hazard with fitted random effects. Use the same event-model interpretation consistently for all subjects.

Why the Formula Has This Form

Let \(N_i(t)\) count whether subject \(i\) has experienced the event by time \(t\), and let \(R_i(t)\) indicate that the subject is still under observation and event-free just before \(t\). Under the specified event model, the accumulated expected event count, conditional on the model information, is the integrated hazard while the subject is at risk. Subtracting that expected count from the observed count gives the martingale process.

$$ M_i(t) = N_i(t) - \int_0^t R_i(s)\lambda_i(s\mid b_i,w_i)\,ds. $$

At the end of observed follow-up, the observed count is \(N_i(U_i)=\Delta_i\), and the integral stops at \(U_i\), because the subject is no longer observed and at risk afterward. Thus

$$ M_i(U_i) = \Delta_i-\int_0^{U_i}\lambda_i(s\mid b_i,w_i)\,ds. $$

Replacing the unknown hazard by its fitted value yields the stated residual. Under a correctly specified intensity, the compensator property makes the event-counting process minus its compensator a martingale. Informally, conditional on the model information, observed event accumulation and expected event accumulation balance over time. The fitted residuals only approximate this ideal property because the hazard parameters and, often, latent effects have been estimated from data.

Worked Example: Constant Fitted Hazard With Right Censoring

Suppose two hypothetical subjects have a fitted constant event hazard of \(0.12\) per year. Subject A experiences the event after 4 years; subject B is censored after 4 years. Assume the fitted hazard is constant over this interval and that the censoring time does not itself count as an event.

For both subjects, the fitted cumulative hazard is

$$ \widehat H(4)=\int_0^4 0.12\,dt=0.12(4)=0.48. $$

For subject A, \(\Delta_A=1\), so

$$ \widehat r_{MA}=1-0.48=0.52. $$

For subject B, \(\Delta_B=0\), so

$$ \widehat r_{MB}=0-0.48=-0.48. $$

The positive residual for A means one event was observed where the fitted cumulative hazard was \(0.48\). The negative residual for B reflects \(0.48\) units of fitted cumulative hazard without an observed event. Neither residual is a probability, and neither alone establishes that the subject was poorly fit.

Working With Time-Varying Fitted Hazards

In joint models, the event hazard may vary with the latent marker trajectory. Even if the baseline hazard is simple, a changing \(m_i(t;b_i)\) can make the subject-specific hazard time-varying. The required calculation is still the area under that fitted hazard through observed follow-up. If an analytic integral is unavailable, numerical integration can be used, provided it is accurate over the full interval and uses the fitted trajectory at the appropriate times.

Worked Example: Integrating a Piecewise Fitted Hazard

Consider a hypothetical subject whose fitted hazard is \(0.08\) per month from month 0 to month 0.5 and \(0.12\) per month from month 0.5 onward. These rates summarize the fitted hazard after accounting for the subject’s covariates and latent marker trajectory. First suppose the subject is censored at month 1.

The fitted cumulative hazard is the sum of the two interval contributions:

$$ \widehat H(1) = (0.08)(0.5)+(0.12)(1-0.5) = 0.04+0.06 = 0.10. $$

Since the subject is censored, \(\Delta=0\), and the martingale residual is

$$ \widehat r_M=0-0.10=-0.10. $$

Now suppose instead that the event occurs at month 0.75. The second interval is then observed for only \(0.75-0.5=0.25\) months:

$$ \widehat H(0.75) = (0.08)(0.5)+(0.12)(0.25) = 0.04+0.03 = 0.07. $$

The event residual is \(1-0.07=0.93\). The event indicator changes from 0 to 1, but the cumulative hazard must also be recalculated at the event time; it is not the cumulative hazard through month 1.

Interpreting the Distribution and Covariate Patterns

Raw martingale residuals are not expected to look like a symmetric normal sample. Since \(\widehat H_i(U_i)\ge 0\), a censored subject has a residual no greater than zero. An event subject has residual \(1-\widehat H_i(U_i)\), which is at most 1 but can be negative when the fitted cumulative hazard exceeds 1. The upper bound and the potential for large negative values produce a characteristically skewed distribution. Therefore, a histogram that is not bell-shaped is not, by itself, evidence of event-model failure.

More informative checks ask whether residuals show systematic structure the fitted event model should have explained. For example, plot residuals against an omitted or included baseline covariate, or summarize their mean within covariate groups. Under a correctly specified model, there should not be a persistent conditional mean pattern after accounting for the model terms and sampling variability. A smooth trend or a consistent group difference can suggest that the covariate effect, functional form, or association with the marker trajectory is inadequate.

Worked Example: Reading a Covariate Pattern Cautiously

Suppose a hypothetical fitted joint model is assessed in four subjects, with a binary covariate \(x\). The table gives each subject’s event status and fitted cumulative hazard through observed follow-up.

Subject\(x\)\(\Delta_i\)\(\widehat H_i(U_i)\)\(\widehat r_{Mi}\)
A110.200.80
B100.30-0.30
C010.900.10
D000.70-0.70

Each residual is calculated as \(\Delta_i-\widehat H_i(U_i)\). For example, subject A has \(1-0.20=0.80\), while subject D has \(0-0.70=-0.70\). The mean residual for \(x=1\) is

$$ \frac{0.80+(-0.30)}{2}=0.25, $$

and the mean for \(x=0\) is

$$ \frac{0.10+(-0.70)}{2}=-0.30. $$

This tiny example suggests that the fitted model may have underpredicted event accumulation for \(x=1\) and overpredicted it for \(x=0\). Four subjects provide far too little evidence to conclude that the covariate effect is misspecified. In a real diagnostic, examine the pattern across many subjects, uncertainty, influential observations, and whether the apparent trend persists after appropriate model terms are considered.

Diagnostics, Alternatives, and Limitations

A practical assessment combines the residual values with the data and fitted hazard that generated them. Check that event indicators are coded correctly, censoring times are not counted as events, and cumulative hazards are integrated only through observed follow-up. For a time-varying hazard, verify interval boundaries, units, and numerical integration. Compare residuals across clinically meaningful covariate ranges and inspect smooth trends rather than relying only on arbitrary bins.

A residual pattern can arise for several reasons: an omitted covariate, an incorrect functional form, an inadequate baseline hazard, a poorly represented marker trajectory, or a misspecified association between the marker and event hazard. It can also reflect random variation, a few unusual subjects, or estimation error. Martingale residuals alone generally do not distinguish among these explanations. Nor do they diagnose the longitudinal measurement model simply because that model contributes a trajectory to the fitted event hazard.

The main alternative diagnostic perspectives answer different questions. Longitudinal residuals assess discrepancies between observed and fitted marker measurements; they do not replace an event-component check. Martingale residuals retain a direct event-count-minus-expected-count interpretation, but their skewness can make individual values difficult to compare. Transformations and other survival residuals can offer complementary views, while influence and calibration diagnostics address still different properties. No single residual plot establishes overall joint-model adequacy.

A further limitation is that fitted residuals share estimated parameters and may share estimated random effects. They are consequently dependent and can appear more regular than residuals computed using known parameters. When the sample is small or the latent effects are weakly estimated, treat apparent structure cautiously. A useful diagnostic conclusion is specific and measured: for example, “residuals tend to be positive at higher values of this covariate, suggesting that the fitted event hazard may be too low in that range.”

Common pitfall: A censored subject has \(\Delta_i=0\), so it is tempting to assign a residual of zero. That ignores the fitted event hazard accumulated during observed follow-up. The correct residual is \(0-\widehat H_i(U_i)\), which is nonpositive and becomes more negative as the fitted cumulative hazard increases.
Key takeaway: A martingale residual is the observed event indicator minus the fitted cumulative hazard through observed follow-up. Its skewed marginal shape is expected; systematic covariate or trajectory patterns, interpreted with uncertainty and model context, are the more useful warning signs.

Check Your Understanding

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

  1. A subject is censored after 3 years, and the fitted constant hazard is \(0.10\) per year. Calculate the martingale residual and interpret its sign.
  2. A subject experiences an event at time 2. The fitted hazard is \(0.05\) per year from time 0 to 1 and \(0.15\) per year from time 1 to 2. Calculate the residual.
  3. Why is a strongly skewed histogram of raw martingale residuals not sufficient evidence of event-model misspecification?
  4. Several subjects with high values of a covariate have predominantly positive residuals. What might this indicate, and why is it not conclusive?

Solutions. (1) The cumulative hazard is \(0.10(3)=0.30\). Since the subject is censored, the residual is \(0-0.30=-0.30\); it records fitted cumulative hazard without an observed event. (2) The cumulative hazard is \((0.05)(1)+(0.15)(1)=0.20\). The event residual is \(1-0.20=0.80\). (3) Censored residuals cannot be positive, while event residuals are bounded above by 1 and can be arbitrarily negative as cumulative hazard increases. This structure naturally produces skewness. (4) Positive residuals in that range may indicate that observed event accumulation exceeds what the fitted hazards predict, suggesting the hazard is too low there. Sampling variation, influential subjects, and other model misspecification can also produce the pattern, so it requires further assessment.

Clinical Biostats