Why Use Residuals in Event Models?
A fitted event model can produce plausible hazard ratios and event-risk predictions while still representing the data poorly. Residuals provide a way to examine the fit beyond individual parameter estimates. For time-to-event PK/PD models, two useful quantities are the Cox–Snell residual, which transforms observed event or censoring times onto a cumulative-hazard scale, and the martingale residual, which compares the event actually observed with the event count expected under the fitted model.
These diagnostics answer different questions. Cox–Snell residuals assess the overall distribution implied by the fitted model, including its baseline hazard and exposure effects. Martingale residuals are especially useful for looking for systematic patterns across exposure or other covariates. Neither plot identifies a unique cause of misfit by itself: a residual pattern is evidence to investigate, not proof of a particular model defect.
Definitions and Assumptions
For subject \(i\), let \(T_i\) denote the event time and \(C_i\) the censoring time. With ordinary right censoring, the observed time is \(Y_i=\min(T_i,C_i)\), and \(\delta_i=1\) if the event is observed and \(0\) if the observation is censored. Let \(\hat h_i(t)\) be the fitted hazard conditional on that subject’s modeled covariates and exposure history, and define its fitted cumulative hazard by
The hazard has units of inverse time, while the cumulative hazard and both residuals below are dimensionless. If exposure changes over time, \(\hat h_i(u)\) must use the modeled exposure at time \(u\); the cumulative hazard integrates the resulting hazard over the observation period.
The usual diagnostic interpretation assumes that the conditional hazard model is correctly specified, that censoring is independent of the event time conditional on the modeled information, and that subjects’ event and censoring data are recorded appropriately. The simple exponential-reference result for Cox–Snell residuals also assumes a continuous event-time distribution. Ties or genuinely discrete event times may make that reference approximate.
Why the Cox–Snell Reference Is Exponential
For a correctly specified continuous event-time model, the conditional survival function is \(S_i(t)=\exp[-H_i(t)]\), where \(H_i(t)\) is the true cumulative hazard. Evaluated at an uncensored event time, \(S_i(T_i)\) is uniformly distributed on \((0,1)\). Applying the negative logarithm gives
Thus, if the model and its parameters were known, the transformed event times would follow an exponential distribution with rate 1, written \(R\sim \operatorname{Exp}(1)\). In practice, parameters are estimated, so the residuals are not exactly independent draws from that distribution. Censoring also remains censoring after transformation: a censored subject contributes a censored residual, not an observed event residual.
The practical comparison is therefore between the Kaplan–Meier survival estimate for the Cox–Snell residuals, treating \(\delta_i\) as the event indicator, and the reference curve \(\exp(-r)\). Alternatively, compare the estimated cumulative hazard of the residuals with the straight line \(r\). Systematic departures suggest overall model misfit, but do not by themselves distinguish a baseline-hazard problem from a problem with the exposure effect.
Worked Example: Calculating Cox–Snell Residuals
Suppose a hypothetical fitted model has a constant baseline hazard of \(0.04\) per week and a proportional exposure effect, \(\hat h_i(t)=0.04\exp(0.5x_i)\) per week, where \(x_i\) is a dimensionless exposure measure. For this constant-hazard example, \(\hat H_i(Y_i)=0.04\exp(0.5x_i)Y_i\). Calculate residuals for two subjects.
Subject A has \(x_A=0\), an event at 10 weeks, and \(\delta_A=1\). The fitted hazard is \(0.04\exp(0)=0.04\) per week, so
Subject B has \(x_B=1\), is censored at 8 weeks, and \(\delta_B=0\). The fitted hazard is \(0.04\exp(0.5)=0.06595\) per week, giving
Both residuals are on the cumulative-hazard scale and have no time units. Subject A contributes an observed residual event at \(0.400\); subject B contributes a censored residual at \(0.5276\). Treating B’s censoring time as an event would distort the residual survival estimate.
Martingale Residuals and Exposure Patterns
A martingale residual is the observed event count minus the fitted cumulative hazard accumulated while the subject was under observation. For a single-event model, \(M_i=\delta_i-\hat H_i(Y_i)\). Under a correctly specified intensity model with the stated censoring assumptions, the event-count process minus its integrated hazard has mean zero. This motivates checking whether residuals are centered around zero and whether their pattern changes with covariates.
The residual has a distinctive range. For an event, \(M_i=1-\hat H_i(Y_i)\), which can be positive or negative. For a censored observation, \(M_i=-\hat H_i(Y_i)\), so it is nonpositive. Martingale residuals cannot exceed 1, but can be arbitrarily negative. Their skewness is expected; symmetry around zero is not a required diagnostic feature.
A smooth trend in martingale residuals against a continuous exposure measure can indicate that the exposure relationship is inadequately represented. For example, a systematic curved pattern may prompt consideration of a different exposure link or functional form. This is a diagnostic lead, not an automatic instruction to change the model: exposure distributions, influential observations, time structure, and baseline-hazard misspecification can also affect the pattern. For time-varying exposure, residuals should not be treated as independent repeated observations at every measurement time; the fitted cumulative hazard already incorporates the modeled exposure history.
Worked Example: Computing Martingale Residuals
Use the same hypothetical model, \(\hat h_i(t)=0.04\exp(0.5x_i)\) per week. Subject A has \(x_A=0\), an event at 10 weeks, and subject B has \(x_B=1\), is censored at 8 weeks. The cumulative hazards calculated above are \(0.400\) and \(0.5276\).
For subject A, \(\delta_A=1\), so
For subject B, \(\delta_B=0\), so
A’s positive residual means one event was observed against a fitted cumulative hazard of \(0.400\) by 10 weeks. B’s negative residual means no event was observed by 8 weeks, while the fitted cumulative hazard by that time was \(0.5276\). These individual values do not establish model fit or misfit; patterns across subjects are more informative.
Reading the Diagnostic Plots
For each subject, integrate the fitted hazard over that subject’s observed interval, using the modeled exposure history where appropriate.
Set \(R_i=\hat H_i(Y_i)\) and \(M_i=\delta_i-R_i\). Retain the original event indicator for the censored-data analysis.
Plot the Kaplan–Meier survival estimate for \(R_i\) against \(r\), with \(\exp(-r)\) as reference, or compare its estimated cumulative hazard with \(r\).
Plot martingale residuals against exposure or other continuous covariates, preferably with a smooth trend and a zero reference. Investigate systematic shape rather than isolated points alone.
A Cox–Snell plot that tracks its reference reasonably well supports the overall adequacy of the fitted event-time distribution, but it does not prove that every component is correct. Curvature or persistent divergence can arise from the baseline hazard, exposure relationship, unmodeled heterogeneity, or other misspecification. In a martingale-residual plot, a stable cloud without a systematic trend is more reassuring than a pronounced trend, but residual skewness itself is not a failure.
Worked Example: Comparing a Residual Survival Curve With Its Reference
Consider four hypothetical Cox–Snell residuals with their event indicators: \(0.2\) (event), \(0.5\) (censored), \(0.8\) (event), and \(1.2\) (event). The Kaplan–Meier estimate starts at 1. At residual \(0.2\), all four subjects are at risk and one event occurs, so survival becomes \(1(1-1/4)=0.750\). At \(0.5\), one of the remaining three is censored, so the survival estimate stays at \(0.750\).
At \(0.8\), two subjects remain at risk and one event occurs. The estimate becomes \(0.750(1-1/2)=0.375\). At \(1.2\), the final subject has an event, so the empirical estimate falls to zero. Compare the nonterminal points with the unit-exponential reference:
The two displayed Kaplan–Meier estimates are below their references, but four observations are far too few to establish a reliable discrepancy. In particular, the terminal estimate of zero is a finite-sample consequence of observing an event in the last subject, not evidence that the exponential distribution has zero survival beyond \(1.2\). In an application, assess the whole curve and the amount of data supporting each part of it.
Distinguishing Misspecification and Knowing the Limits
The plots offer complementary rather than interchangeable evidence. A Cox–Snell plot compresses the whole fitted model into one distributional check. Martingale residuals retain a subject-level connection to observed events and can reveal covariate-related structure. If the Cox–Snell plot departs from its reference and martingale residuals also vary systematically with exposure, the exposure component deserves scrutiny; if the overall residual plot departs without a clear exposure pattern, the baseline hazard or another component may be responsible. Neither pattern isolates the cause conclusively.
| Diagnostic | Main use | Important caution |
|---|---|---|
| Cox–Snell residual survival or cumulative-hazard plot | Assess overall agreement with the fitted event-time distribution | Does not identify which model component caused a departure |
| Martingale residuals versus exposure or covariates | Look for systematic covariate-related patterns, including possible link misspecification | Skewness is expected; a pattern may have more than one explanation |
| Proportional-hazards diagnostics | Assess whether relative hazards change over time | Addresses a different question from overall residual distribution or exposure functional form |
These diagnostics do not replace examination of the fitted model’s assumptions or the proportional-hazards checks covered in the earlier material on Diagnosing Proportional Hazards in PK/PD. They also do not establish predictive calibration in new data, a question addressed separately by calibration and predictive checks. With estimated parameters, residuals depend on the same data used to fit the model; small samples, heavy censoring, influential subjects, and sparse exposure ranges can make plots unstable or uninformative. For delayed entry, competing risks, or recurrent events, the basic single-event formulas and reference plots require the corresponding risk-set or event-process formulation rather than uncritical application.
Common Mistakes
- Counting censored observations as events. A censored subject contributes \(R_i=\hat H_i(Y_i)\) with event indicator zero; censoring is not an observed event.
- Expecting martingale residuals to look normally distributed. Their upper bound is 1 and their negative tail is unbounded. Look for systematic structure, not symmetry.
- Claiming a residual plot identifies the faulty model component. A Cox–Snell departure indicates overall misfit, not whether the baseline hazard or exposure link is responsible.
- Calling a weak trend proof of a correct model. Heavy censoring, limited exposure variation, or few events can conceal important misspecification.
Check Your Understanding
Answer each question, then compare with the solutions below.
- A subject is censored at 6 weeks, and the fitted constant hazard is \(0.05\) per week. Calculate the Cox–Snell and martingale residuals.
- For an event observed at 12 weeks, the fitted constant hazard is \(0.03\) per week. Calculate the martingale residual and interpret its sign.
- What does a systematic departure of the Cox–Snell residual survival curve from \(\exp(-r)\) indicate, and what can it not establish?
- Why is a curved martingale-residual pattern against exposure worth investigating, and why is it not proof that the exposure link is wrong?
Solutions. (1) The cumulative hazard is \(0.05(6)=0.300\), so \(R=0.300\). Since the subject is censored, \(\delta=0\), and \(M=0-0.300=-0.300\). (2) The cumulative hazard is \(0.03(12)=0.360\), so \(M=1-0.360=0.640\). The positive value indicates one observed event against a fitted cumulative hazard of \(0.360\); it is not, on its own, evidence of misfit. (3) It suggests overall disagreement between the fitted event-time distribution and the data under the diagnostic assumptions. It does not identify whether the baseline hazard, exposure effect, or another component is responsible. (4) Curvature may signal that the modeled exposure relationship does not capture the pattern in the data. But baseline-hazard problems, influential observations, sparse exposure information, or chance variation can also produce an apparent trend, so further model assessment is needed.