
Six-month Kaplan–Meier survival curves for patients with end-stage dementia divided into high, medium, and low MSSE score groups, illustrating group comparisons of survival data. These curves are not the veteran example used later in this article. The site copy adds a “研究方法” watermark at the bottom right. Author: Amisffs. Source: Wikimedia Commons. License: CC BY-SA 4.0.
The Cox proportional hazards model is one of the core regression methods in survival analysis. It does not specify how the baseline hazard changes over time; it assumes only that covariates multiply the baseline hazard exponentially, allowing hazard ratios to be estimated. Drawing on Cox's original 1972 paper and modern textbooks, this article explains how to interpret hazard ratios, diagnose the proportional hazards assumption, and address violations through stratification or time-varying coefficients, and provides a reproducible R example.
Multiplicative Hazards and Hazard Ratios
Cox's paper “Regression Models and Life-Tables,” published in 1972 in Series B of the Journal of the Royal Statistical Society, discusses censored failure times: each individual has one or more explanatory variables, and the hazard function—the instantaneous failure rate measured by age or follow-up time—is expressed as “a function of explanatory variables and unknown regression coefficients” multiplied by “an arbitrary, unknown function of time.” A common notation today is h(t | x) = h₀(t) · exp(β₁x₁ + β₂x₂ + … + βₚxₚ). Here, h₀(t) is the baseline hazard when all covariates are 0. The model makes no assumptions about its shape, while the covariate component is parameterized, which is why the Cox model is often called a semiparametric model.
“Proportional” refers to the ratio between the hazards of two individuals. The hazard ratio for individual a versus individual b is h(t | xa) / h(t | xb) = exp[β(xa − xb)]; h₀(t) cancels in the division, so the ratio does not change over time. In other words, covariates raise or lower the entire baseline hazard curve by a fixed multiplier without changing the shape of its fluctuations over time. Taking logarithms turns this multiplicative effect into a shift in the log hazard.
Estimating β likewise does not require knowing h₀(t). Cox's original paper constructed a conditional likelihood, later commonly called the partial likelihood: at each observed event time, all individuals still at risk—the risk set—are considered together to calculate the conditional probability that “this particular individual experiences the event,” exp(βxᵢ) / Σⱼ∈R(tᵢ) exp(βxⱼ). Because h₀(tᵢ) appears in both the numerator and denominator and cancels, the regression coefficients can be inferred using only the order of events and the risk set at each time. Censored individuals remain in the risk set until censoring, so the information they provide is not discarded.
exp(βₖ) is the hazard ratio (HR): holding other covariates constant, each 1-unit increase in xₖ multiplies the instantaneous hazard at any time by exp(βₖ). In the veteran data used below, for example, the coefficient for the Karnofsky performance score is −0.033771, and exp(−0.033771) ≈ 0.967. Thus, each 1-point increase in score corresponds to a hazard approximately 0.967 times the original value. For a more clinically meaningful 10-point increase, exp(−0.33771) ≈ 0.71, indicating a hazard approximately 29% lower. Three points matter when interpreting this. First, a hazard ratio compares instantaneous hazards; it is neither the ratio of cumulative proportions who have died by a particular time nor the ratio of survival times. HR = 0.71 does not mean “survival time increases to 1/0.71 times its original value.” Second, the coefficient depends on the variable's units, so reports should specify the size of the increase. Third, when proportional hazards does not hold, a single hazard ratio is merely a form of average over the entire follow-up period and can conceal patterns such as “a strong early effect that almost disappears later.” The example below illustrates this situation.
Diagnosing the Proportional Hazards Assumption
The proportional hazards assumption can be written as β(t) = β, meaning that covariate effects do not change over time. Kleinbaum and Klein's textbook groups methods for checking it into three categories: graphical methods, goodness-of-fit tests, and adding interactions between covariates and time to the model. The first two are most common in routine practice, corresponding to log-minus-log plots and tests based on Schoenfeld residuals.
A Schoenfeld residual is calculated for each covariate for each individual who experiences an event: if someone experiences an event at time t, their residual equals their own covariate value minus the weighted average of that covariate among individuals in the risk set at t, with weights given by their hazards. If proportional hazards holds, these residuals should be unrelated to time. Grambsch and Therneau (1994) further showed that plotting scaled Schoenfeld residuals against time and smoothing them yields an estimate of β(t). Various existing tests, including those of Cox (1972) and Schoenfeld (1980), can be viewed as time-weighted score tests that fit a weighted least-squares line to this residual plot and test whether its slope is 0. The R survival package implements this through cox.zph(): it reports score tests for each variable and a global test, while plot() draws β(t) curves with approximate confidence bands. Under proportional hazards, the curves should be approximately horizontal. By default, the time axis uses a Kaplan–Meier transformation (transform = "km"); ranks, untransformed time, or a custom function can also be used, with different transformations emphasizing different periods. The help documentation also explains that versions before survival 3.0 computed a fast approximation to the score test, whereas later versions use the actual score test, so numerical results can differ between older and newer versions.
Log-minus-log plots start from the survival function. Under the Cox model, S(t | x) = exp[−H₀(t) · exp(βx)], and taking logarithms twice gives log[−log S(t | x)] = log H₀(t) + βx. Curves for different covariate groups differ only by the constant βΔx. Thus, when log(−log Ŝ(t)) from group-specific Kaplan–Meier estimates is plotted against log t, the curves should be roughly parallel if proportional hazards holds. Clear crossings or progressive convergence signal a violation. In R, these plots can be produced with plot(survfit(...), fun = "cloglog"); continuous variables must first be divided into groups. The textbook also notes that this assessment is subjective: there is no standard for how parallel is parallel enough, and small samples are particularly difficult to assess. It therefore recommends a conservative approach, avoiding a conclusion of violation unless there is clear evidence of nonparallel curves.
Tests and plots should be considered together. The survival package vignette cautions that the proportional hazards assumption never holds exactly, and summarizing effects with an average is often reasonable. However, even a small departure can be significant in a large sample, while a small sample can fail to detect a clear departure. What truly requires attention is a departure large enough to make a single hazard ratio misleading.

AI-generated schematic. The site copy adds a “研究方法” watermark at the bottom right. this illustrates only the approximate pattern of the time-varying Karnofsky score coefficient β(t) estimated by cox.zph. The blue line represents smoothed β(t) with its confidence band, the gray line marks 0, and the red dashed line represents the time-invariant coefficient from an ordinary Cox model. The survival package vignette describes the effect as clearly negative early on and not far from 0 after approximately 200 days. The curves shown were not generated by actually running the veteran data, and the figure has no scale markings; use the example output below for specific numerical values.
Stratification and Time-Varying Coefficients When the Assumption Is Violated
After identifying a violation, first consider its source. The effect itself might change over time, as when a treatment effect gradually weakens; the variable's functional form might be misspecified; or selection effects might be involved. In the veteran data below, patients with an initial Karnofsky score no higher than 40 account for 28% at the start of the study but only 4% of those remaining at day 200. Different causes call for different approaches.
Stratification is suitable when the variable violating the assumption is categorical and needs adjustment but is not itself the focus of the study, such as study center or pathological type. In R, this is written as strata(variable). Each stratum has its own baseline hazard h₀ₛ(t), whose shape can differ completely, while coefficients for the other covariates are shared across strata. The trade-off is that the stratification variable no longer appears as a covariate in the model, so its hazard ratio cannot be obtained. Continuous variables must also be grouped before stratification.
Time-varying coefficients directly express β as a function of time, β(t), and are suitable when researchers are interested in how an effect changes over time. The simplest form is a step function: survSplit() divides each individual's follow-up into several intervals, with a separate coefficient estimated for each interval. A continuous form can also be assumed, such as β(t) = a + b · log(t + 20), and fitted using the tt() time transformation in coxph(). The survival package specifically warns against writing I(x * log(time)): this constructs a fixed value using each individual's final follow-up time, effectively “looking into the future,” and can mistakenly treat longer follow-up as a cause of longer survival. Newer versions of coxph() report an error for this formulation. Another pitfall is choosing cut points after inspecting the residual plot; subsequent tests of whether interval-specific coefficients differ are then biased.
An R Example Using the veteran Data
The following example demonstrates the full workflow using the veteran cancer data included in the survival package: there are 137 patients and 128 deaths; trt denotes treatment group, prior denotes prior treatment, and karno denotes the Karnofsky score. The code follows the survival package vignette by Therneau, Crowson, and Atkinson (January 12, 2026 version). Numerical output is taken from that vignette and was not rerun locally when this article was written. The current version on CRAN is survival 3.8-12 (released September 9, 2026), and results can differ slightly across versions. The two sections marked “output not given in the vignette” are additions in this article; the vignette does not provide their output, and readers can run them to inspect the results.
library(survival)
options(show.signif.stars = FALSE)
# 1. Ordinary Cox model
vfit <- coxph(Surv(time, status) ~ trt + prior + karno, data = veteran)
vfit
# 2. PH test and beta(t) plot from scaled Schoenfeld residuals
zp <- cox.zph(vfit, transform = function(time) log(time + 20))
zp
plot(zp[3]); abline(h = 0, lty = 3)
# 3. Log-minus-log curves by Karnofsky group (output not given in the vignette)
km <- survfit(Surv(time, status) ~ I(karno > 60), data = veteran)
plot(km, fun = "cloglog", col = 1:2,
xlab = "Days (log scale)", ylab = "log(-log S(t))")
# 4a. Step-function coefficient: 0-90, 90-180, >180 days
vet2 <- survSplit(Surv(time, status) ~ ., data = veteran,
cut = c(90, 180), episode = "tgroup", id = "id")
vfit2 <- coxph(Surv(tstart, time, status) ~ trt + prior + karno:strata(tgroup),
data = vet2)
vfit2
cox.zph(vfit2)
# 4b. Continuous time-varying coefficient: beta(t) = a + b * log(t + 20)
vfit3 <- coxph(Surv(time, status) ~ trt + prior + karno + tt(karno),
data = veteran, tt = function(x, t, ...) x * log(t + 20))
vfit3
# 4c. Stratified model by cell type (output not given in the vignette)
vfit_s <- coxph(Surv(time, status) ~ trt + prior + karno + strata(celltype),
data = veteran)
# vfit: ordinary Cox model (n = 137, events = 128)
coef exp(coef) se(coef) z p
trt 0.180197 1.197453 0.183468 0.982 0.326
prior -0.005551 0.994464 0.020225 -0.274 0.784
karno -0.033771 0.966793 0.005114 -6.604 4e-11
# cox.zph(vfit, transform = log(time + 20))
chisq df p
trt 0.271 1 0.60247
prior 2.260 1 0.13275
karno 10.694 1 0.00107
GLOBAL 16.881 3 0.00075
# vfit2: karno coefficient by interval (225 rows, 128 events)
karno, 0-90 days -0.048755 p = 4.64e-15
karno, 90-180 days 0.008050 p = 0.530
karno, >180 days -0.008349 p = 0.568
cox.zph(vfit2) GLOBAL: chisq = 8.03, df = 5, p = 0.154
# vfit3: continuous time-varying coefficient
karno -0.124662 se = 0.028785 p = 1.49e-05
tt(karno) 0.021310 se = 0.006607 p = 0.00126
In the ordinary Cox model, karno is highly significant, but its proportional hazards test in cox.zph gives p = 0.00107, indicating that its effect changes over time. After dividing follow-up into 0–90 days, 90–180 days, and more than 180 days, the hazard ratio per 10-point increase in score during the first 90 days is exp(−0.48755) ≈ 0.61. The coefficients for the later two intervals are close to 0 and nonsignificant, and the interval-specific model's global proportional hazards test gives p = 0.154. The continuous form estimates β(t) = −0.125 + 0.021 · log(t + 20): at the start of follow-up, the hazard ratio per 10-point increase in score is approximately exp(−0.608) ≈ 0.54; by day 200 it is approximately exp(−0.097) ≈ 0.91, already close to 1. By comparison, the ordinary model's 0.71 (per 10 points) is merely an average over the entire follow-up period. The vignette also explains the limitations: this log-linear curve is too high after 200 days and underestimates the initial slope; the interval cut points were chosen after inspecting the plot, making tests of differences between intervals biased. The vignette offers two explanations for the weakening effect: in acute disease, a measurement taken six months earlier is no longer relevant, or the large number of early deaths among patients with low scores creates selection. It does not determine which explanation holds.
The Roles of Kaplan–Meier and AFT Models
The Kaplan–Meier method directly estimates each group's survival curve S(t) without specifying a model. It is often paired with a log-rank test to compare groups and is suitable for description and preliminary comparisons. However, it can only form groups using a small number of categorical variables and cannot simultaneously adjust for multiple continuous covariates. It is also useful in Cox analysis: the log-minus-log plots above are transformations of group-specific Kaplan–Meier curves.
The Cox model occupies an intermediate position: its covariate component is parameterized, its baseline hazard has no specified shape, and it produces adjusted hazard ratios. It does not directly provide absolute survival probabilities. To plot a predicted survival curve for a particular type of patient, the baseline cumulative hazard must be estimated after fitting for specified covariate values. The survival package vignette cautions that the default curve uses the mean of each covariate—for example, 1.47 for treatment group—which does not correspond to any actual individual. Patient characteristics should be explicitly specified using newdata.
Accelerated failure time (AFT) models are parametric models that require choosing a distribution, such as Weibull, log-normal, or log-logistic, and express covariate effects on the time scale. Their key quantity is the acceleration factor: the ratio of survival times between two groups at any given survival probability. An acceleration factor of 2 means that both median survival time and the time required to reach any survival proportion are doubled. Exponential and Weibull models satisfy both the proportional hazards and AFT assumptions, differing only in parameterization; the log-logistic model is an AFT model but not a proportional hazards model. AFT models can be considered when the research question itself is “how long was the event delayed?” or when the hazard ratio clearly varies over time and describing time as being stretched or compressed overall is more appropriate. The trade-off is that the distributional assumption must be checked. Parametric AFT models in the survival package are fitted using survreg().
| Method | Assumption about time | Main output |
|---|---|---|
| Kaplan–Meier | No model specified | Group-specific survival curves and median survival times |
| Cox proportional hazards model | No specified shape for the baseline hazard; hazard ratios remain constant over time | Hazard ratios |
| Accelerated failure time model | Survival times follow a chosen distribution | Acceleration factors (ratios of survival times) |
References
-
Cox, D. R. (1972). Regression Models and Life-Tables. Journal of the Royal Statistical Society: Series B (Methodological), 34(2), 187–220. https://doi.org/10.1111/j.2517-6161.1972.tb00899.x
-
Grambsch, P. M., & Therneau, T. M. (1994). Proportional hazards tests and diagnostics based on weighted residuals. Biometrika, 81(3), 515–526. https://doi.org/10.1093/biomet/81.3.515
-
Kleinbaum, D. G., & Klein, M. (2012). Survival Analysis: A Self-Learning Text (3rd ed.). Springer. https://doi.org/10.1007/978-1-4419-6646-9
-
Therneau, T., Crowson, C., & Atkinson, E. (2026, January 12). Using Time Dependent Covariates and Time Dependent Coefficients in the Cox Model. R survival package vignette. https://cran.rstudio.com/web/packages/survival/vignettes/timedep.Rnw
-
R survival package help documentation: cox.zph https://stat.ethz.ch/R-manual/R-devel/library/survival/html/cox.zph.html; plot.survfit https://stat.ethz.ch/R-manual/R-devel/library/survival/html/plot.survfit.html
-
Therneau, T. M., et al. survival: Survival Analysis (R package version 3.8-12, 2026-09-09). CRAN. https://CRAN.R-project.org/package=survival
-
Research Methods · Rituals can be imitated; understanding cannot be faked
-
Information compiled and published by the Scholay One-Stop Academic Platform. If any content infringes your rights, please notify us to request its removal.
-
This information is also published on EnterScholar, a community for scholars in the age of intelligence.