Inferensys

Glossary

Schoenfeld Residuals

Diagnostic residuals used to test the proportional hazards assumption in Cox regression by checking if covariate effects remain constant over time, often visualized with the Grambsch-Therneau test.
Developer demonstrating multi-agent tool use, agent tool selection interface on laptop, casual tech demo moment.
PROPORTIONAL HAZARDS DIAGNOSTICS

What are Schoenfeld Residuals?

Schoenfeld residuals are diagnostic tools used to test the proportional hazards assumption in the Cox model by measuring the difference between an observed covariate value and its expected value at each event time.

Schoenfeld residuals are defined as the difference between the observed covariate value for a subject experiencing an event and a weighted average of covariate values across the risk set at that event time. Formally, for each event time (t_i), the residual for covariate (k) is (r_{ik} = x_{ik} - \sum_{j \in R(t_i)} x_{jk} \hat{p}_j), where (R(t_i)) is the risk set and (\hat{p}_j) is the estimated probability of subject (j) failing. These residuals are defined only at failure times, not for censored observations.

The primary application is the Grambsch-Therneau test, which scales Schoenfeld residuals by an estimate of the covariance matrix and regresses them against time. A non-zero slope indicates violation of the proportional hazards assumption—that the hazard ratio between groups remains constant over time. A significant p-value or a systematic pattern in a smoothed residual plot suggests the covariate's effect changes with time, requiring remedies like time-varying coefficients or stratification.

DIAGNOSTIC RESIDUALS

Key Statistical Properties

Schoenfeld residuals are the cornerstone diagnostic for validating the proportional hazards assumption in survival analysis. Each card below unpacks a distinct statistical property essential for rigorous model checking.

01

Definition and Mathematical Form

A Schoenfeld residual is defined for each covariate at each observed event time. It is the difference between the observed covariate value for the individual who experienced the event and the expected value of that covariate, given the risk set at that time. Formally, for subject i with covariate vector X_i who fails at time t_i, the residual is r_i = X_i - E[X | R(t_i)], where the expectation is a weighted average over all individuals still at risk. These residuals are not defined for censored observations, only for actual event times.

Per Event
Granularity Level
Zero Mean
Asymptotic Property
02

Testing the Proportional Hazards Assumption

The core purpose of Schoenfeld residuals is to test whether a covariate's effect is constant over time. If the proportional hazards assumption holds, the residuals should exhibit no systematic trend when plotted against time. A non-zero slope indicates a time-varying coefficient, violating the assumption. The formal Grambsch-Therneau test computes a correlation coefficient between the scaled residuals and a function of time (typically the Kaplan-Meier survival estimate). A significant p-value (< 0.05) provides strong evidence against the null hypothesis of proportional hazards.

Grambsch-Therneau
Standard Test
p < 0.05
Violation Threshold
03

Scaled Schoenfeld Residuals

Raw Schoenfeld residuals are difficult to interpret directly because their variance depends on the covariate distribution. Scaled Schoenfeld residuals multiply the raw residual vector by an estimate of the inverse of the Cox model's information matrix. This scaling produces residuals that are:

  • Standardized: Easier to visualize and compare across covariates.
  • Additive: The scaled residual for a subject approximates the change in the estimated coefficient if that subject were removed.
  • Directly Interpretable: A smoothed plot of scaled residuals plus the original coefficient estimate reveals the functional form of the time-varying effect.
Coefficient Change
Interpretation Unit
04

Visual Diagnostics and Smoothing

Visual inspection of Schoenfeld residuals is standard practice. A plot of scaled residuals vs. time with a loess smoother overlaid reveals the nature of any violation:

  • Horizontal line: Supports proportional hazards.
  • Upward/downward trend: Indicates a covariate effect that increases or decreases over time.
  • Non-linear pattern: Suggests a complex time interaction. The cox.zph() function in R's survival package generates these plots automatically, displaying the smoother and a confidence band. Outliers in the plot may also identify influential observations that disproportionately affect the model fit.
Loess Smoother
Visualization Method
05

Remedies for Violations

When Schoenfeld residuals reveal a violation, several modeling strategies can address the non-proportionality:

  • Stratification: Fit separate baseline hazards for levels of the offending categorical covariate, allowing the baseline hazard to differ while assuming proportional hazards for other covariates.
  • Time-by-Covariate Interaction: Include an explicit interaction term between the covariate and a function of time, such as log(t) or a step function, in the Cox model.
  • Accelerated Failure Time (AFT) Model: Switch to a parametric model that does not assume proportional hazards, such as Weibull or log-normal regression.
  • Landmark Analysis: Analyze survival conditional on surviving to a specific time point, effectively allowing effects to vary across time windows.
Stratification
Primary Remedy
Time Interaction
Alternative Approach
06

Relationship to Martingale Residuals

Schoenfeld residuals are mathematically connected to martingale residuals, another key diagnostic in survival analysis. While martingale residuals assess the overall adequacy of the model's functional form for continuous covariates, Schoenfeld residuals specifically target the time-constancy of effects. A key distinction:

  • Martingale residuals: Defined for every subject (censored and uncensored), range from -∞ to 1, and detect non-linearity in covariate effects.
  • Schoenfeld residuals: Defined only at event times, sum to zero asymptotically, and detect time-varying coefficients. Together, they form a complementary diagnostic suite for Cox model validation.
Complementary
Diagnostic Role
Event Times Only
Schoenfeld Scope
DIAGNOSTIC DEEP DIVE

Frequently Asked Questions

Clarifying the role of Schoenfeld Residuals in validating the proportional hazards assumption for reliable survival analysis.

Schoenfeld Residuals are diagnostic residuals used specifically to test the proportional hazards assumption in a Cox regression model. They work by measuring the difference between the observed covariate value for a subject that experiences an event at a specific time and the expected value of that covariate, given the risk set still at risk just before that event time. Unlike standard regression residuals, they are defined only at event times, not for censored observations. If the proportional hazards assumption holds, these residuals should be independent of time, appearing as a random scatter around zero when plotted against the time axis. A systematic trend, such as a positive slope, indicates that the effect of the covariate—the hazard ratio—is changing over the observation period, violating the model's core premise.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.