Inferensys

Glossary

Martingale Residuals

Residuals used to assess the functional form of covariates in a Cox model by plotting them against continuous predictors to detect non-linearity or outliers.
ML engineer running AI model benchmarks, performance charts on multiple screens, late night home office setup.
Cox Model Diagnostics

What is Martingale Residuals?

Martingale residuals are diagnostic statistics used to assess the functional form of continuous covariates in a Cox proportional hazards model by identifying non-linearity and detecting outliers in survival data.

A martingale residual is defined as the difference between the observed number of events for a subject and the expected number of events predicted by the fitted Cox model over their follow-up period. Ranging from negative infinity to one, these residuals represent the discrepancy between the observed event indicator and the model's estimated cumulative hazard, providing a direct measure of how well the model captures an individual's survival experience.

Plotting martingale residuals against a continuous covariate or against the linear predictor reveals whether the assumed functional form is correct. A systematic, non-random pattern—such as a curve—indicates a non-linear relationship requiring transformation, while residuals far below zero may flag potential outliers or subjects with unexpectedly short survival times relative to their covariate profile.

MARTINGALE RESIDUALS

Frequently Asked Questions

Explore the diagnostic mechanics of martingale residuals, the essential tool for assessing the functional form of continuous covariates in Cox proportional hazards models and detecting non-linearity in survival data.

A martingale residual is a diagnostic metric derived from the Cox proportional hazards model that quantifies the discrepancy between the observed number of events and the model-predicted cumulative hazard for each subject over their follow-up period. Formally, it is calculated as the difference between the observed event indicator (δᵢ) and the estimated cumulative hazard (Ĥᵢ(tᵢ)): r̂ₘᵢ = δᵢ - Ĥᵢ(tᵢ). These residuals range from negative infinity to +1, where a value near +1 indicates a subject who experienced an event much earlier than predicted, and a large negative value suggests a subject who survived longer than expected or was censored. Unlike standard linear regression residuals, martingale residuals are inherently asymmetric due to the censoring mechanism, making them uniquely suited for detecting non-linearity in covariate effects and identifying outliers in time-to-event data.

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.