You have a dataset of 299 heart failure patients. Some survived, some did not. You know their ejection fractions, serum creatinine levels, ages, and comorbidities. The question your department chief and your manuscript reviewers both want answered: which factors predict time to death, and by how much does each one change the risk? Cox proportional hazards analysis answers that question with hazard ratios, Kaplan-Meier survival curves, and concordance statistics. The method is well established. Access to SAS, Stata, or a biostatistics core can be the barrier. Upload a CSV to ask for a survival analysis.
Worked Example (Simulated): Risk Score and Treatment
Question: In made-up patient data, how are a risk score and treatment group linked to time before an event?
Inputs: Simulated data, seed 2026. The script makes a risk score, a treatment flag, event times, and censor times. A censor time marks the end of follow-up when no event was seen. The script sets the effects (log hazard 0.55 for the risk score and -0.50 for treatment, which are hazard ratios of 1.73 and 0.61), then fits them back. It writes the Cox fit by hand and uses no survival library.
Method: Fit a Cox model, a model for time until an event. It uses the risk score and treatment in one model. The hazard ratio (HR) compares the hazard of the event between groups at a given time. This meaning depends on the model's proportional hazards rule: the ratio stays steady over time.
import numpy as np
from scipy.optimize import minimize
rng = np.random.default_rng(2026)
n = 160
risk = rng.normal(size=n)
treatment = rng.integers(0, 2, size=n)
X = np.column_stack((risk, treatment))
true_beta = np.array([0.55, -0.50])
event_time = rng.exponential(scale=1 / (0.04 * np.exp(X @ true_beta)))
censor_time = rng.exponential(scale=1 / 0.012, size=n)
time = np.minimum(event_time, censor_time)
event = (event_time <= censor_time).astype(int)
event_rows = np.flatnonzero(event)
def objective_and_gradient(beta):
loss = 0.0
gradient = np.zeros(X.shape[1])
for i in event_rows:
rows = time >= time[i]
z = X[rows] @ beta
weights = np.exp(z - np.max(z))
weights /= weights.sum()
mean_x = weights @ X[rows]
loss += np.log(np.exp(z - np.max(z)).sum()) + np.max(z) - X[i] @ beta
gradient += mean_x - X[i]
return loss, gradient
fit = minimize(objective_and_gradient, np.zeros(X.shape[1]), jac=True,
method="BFGS", options={"gtol": 1e-8})
beta = fit.x
information = np.zeros((X.shape[1], X.shape[1]))
for i in event_rows:
rows = time >= time[i]
z = X[rows] @ beta
weights = np.exp(z - np.max(z))
weights /= weights.sum()
mean_x = weights @ X[rows]
centered = X[rows] - mean_x
information += (centered * weights[:, None]).T @ centered
se = np.sqrt(np.diag(np.linalg.inv(information)))
print("Simulated data, seed 2026")
print(f"Patients: {n}; events: {event.sum()}; censored: {n - event.sum()}")
print("Cox model: time to event ~ risk score + treatment (0/1)")
for name, b, s in zip(("Risk score, per 1 unit", "Treatment, 1 vs 0"), beta, se):
hr = np.exp(b)
lo, hi = np.exp(b - 1.96 * s), np.exp(b + 1.96 * s)
print(f"{name}: HR {hr:.2f}; 95% CI {lo:.2f} to {hi:.2f}")
print(f"Optimizer success: {fit.success}")
Printed output:
Simulated data, seed 2026
Patients: 160; events: 110; censored: 50
Cox model: time to event ~ risk score + treatment (0/1)
Risk score, per 1 unit: HR 1.77; 95% CI 1.47 to 2.13
Treatment, 1 vs 0: HR 0.54; 95% CI 0.37 to 0.80
Optimizer success: True
Result: The risk score's fitted HR is above one. In this made-up set, a higher score links to a higher hazard of the event. The treatment HR is below one. After accounting for the score, treatment flag one links to a lower hazard of the event. The data were built with these effects, and the fit lands near them (1.77 against 1.73, and 0.54 against 0.61). See the output for estimates and confidence intervals.
Limit: These data are made up. They do not show a real treatment effect. This example does not check the proportional hazards rule.
Sources
- Cox D (1972). Regression Models and Life-Tables. Journal of the Royal Statistical Society, Series B. doi 10.1111/j.2517-6161.1972.tb00899.x.
- Grambsch P, Therneau T (1994). Proportional hazards tests and diagnostics based on weighted residuals. Biometrika. doi 10.1093/biomet/81.3.515. Cited where this page mentions checking proportional hazards.
These papers are cited for who published the method and when. No number on this page comes from them.
Why Clinical Research Needs Survival Analysis
Time-to-event outcomes are the foundation of clinical research. In oncology, overall survival and progression-free survival are common primary endpoints. In cardiology, time to rehospitalization or cardiac death drives treatment guidelines. In transplant medicine, graft survival determines organ allocation protocols. The Cox proportional hazards model, introduced by Cox in 1972, is widely used to analyze these outcomes.
The method produces hazard ratios, which are directly interpretable in clinical practice. A hazard ratio of 1.5 for serum creatinine above 1.9 mg/dL means that patients with elevated creatinine experience death at 1.5 times the rate of those with normal levels, after adjusting for all other factors in the model. This is the language of clinical decision-making. It appears in treatment guidelines, drug labels, and clinical protocols. Unlike machine learning classifiers that output opaque risk scores, Cox regression tells you both the direction and magnitude of each risk factor.
Despite its ubiquity, the method often sits behind commercial software licenses and technical barriers: SAS and Stata are licensed products (see each vendor for current pricing). R's survival package is free but demands programming skill that many clinical fellows, nursing researchers, and outcomes analysts do not have. The practical result is a bottleneck: researchers may wait for a biostatistics consultation to produce an analysis they could interpret themselves if the software barrier were removed.
When to Use Survival Analysis in Clinical Research
Survival analysis is the right method whenever your outcome is "time until an event." The event can be death, relapse, hospital readmission, disease progression, graft rejection, or any clinically meaningful occurrence. Three conditions must hold for the analysis to be valid:
- You have a time component. Each patient has a follow-up duration measured in days, weeks, or months from enrollment, diagnosis, or procedure.
- Some patients have not experienced the event. Patients who are still alive, still in remission, or lost to follow-up are "censored." The Cox model uses their partial information correctly rather than discarding them or pretending the event happened at the censoring time.
- You want to know which factors predict the timing. If you only want to know whether an event occurred (regardless of when), logistic regression may suffice. Survival analysis answers the more informative question: how quickly does the event happen, and what accelerates or slows it?
Oncology outcomes research. Overall survival and progression-free survival are two endpoints used in cancer studies. The Cox model estimates treatment effects as hazard ratios while adjusting for tumor stage, performance status, age, and biomarkers. If a model gave a hazard ratio of 0.72 for a new therapy, that would mean a 28% lower hazard of death or progression in the drug group than in the control group. This depends on the model's proportional hazards rule and any stated adjustments. Hazard is not the same as event rate.
Cardiology and heart failure. Time to rehospitalization, time to cardiac death, and time to major adverse cardiac events (MACE) are standard survival endpoints. A heart failure example could model time to death using measures such as ejection fraction and serum creatinine. Give the data source, model terms, and fitted output before making claims.
Transplant medicine. Graft survival following kidney, liver, or heart transplant is modeled with Cox regression to identify donor factors, recipient factors, and immunosuppressive regimens that influence long-term outcomes. Hazard ratios from these models directly inform organ allocation scoring systems.
Hospital readmission research. In FY 2026, 240 hospitals (8.1%) will pay readmission penalties of 1% or more under CMS's Hospital Readmissions Reduction Program, up from 208 in 2025 (Advisory Board, 2025). Survival analysis of time-to-readmission, stratified by diagnosis and adjusted for patient acuity, gives hospital quality teams the evidence they need to target interventions to the highest-risk groups.
What Data You Need
A CSV export from your clinical registry, EHR research extract, REDCap database, or cancer registry. The dataset needs three essential elements:
- Time column: follow-up duration in days, weeks, or months from a defined starting point (enrollment, diagnosis, surgery date)
- Event indicator: binary column (1 = event occurred, 0 = censored). Censored means the patient was still being followed without the event at the last observation.
- Predictor columns: patient characteristics you want to test: age, sex, lab values (ejection fraction, creatinine, hemoglobin), comorbidity flags (diabetes, hypertension), treatment group, disease stage
A Cox model is limited by the number of events, not only the number of patients. The example above has 110 events.
Most HRIS and clinical research systems can produce this export. REDCap has a built-in CSV export. SEER registry data comes in this format. Hospital EHR research databases (Epic Caboodle, Cerner HealtheDataLab) support custom research extracts with follow-up time calculated from admission or diagnosis date.
How to Read the Report
Kaplan-Meier survival curves. The curves show the probability of surviving past each time point, stratified by a key grouping variable (treatment arm, disease stage, or a clinical cutoff). Curves that drop steeply represent groups that experience the event quickly. Flat curves represent groups with better outcomes. The separation between curves is the visual representation of the treatment or risk factor effect. If two curves diverge early and stay separated, the effect is strong and consistent.
Hazard ratio forest plot. This is the centerpiece for clinical interpretation. Each predictor gets a horizontal bar showing its hazard ratio and 95% confidence interval. Ratios above 1.0 mean the factor accelerates the event (risk factor). Ratios below 1.0 mean the factor is linked to a lower hazard. If the confidence interval crosses 1.0, the effect is not statistically significant.
Coefficient table. The companion to the forest plot, formatted for direct inclusion in a manuscript. Shows the raw log-hazard coefficient, standard error, z-statistic, p-value, and exponentiated hazard ratio with confidence interval for each predictor. This is the standard Table 2 in a clinical survival analysis publication, following STROBE reporting guidelines.
Concordance index (C-statistic). Measures the model's ability to discriminate between patients who experience the event sooner versus later. A C-index of 0.5 means the model ranks no better than chance.
Proportional hazards diagnostics. The Schoenfeld residual plots and formal statistical tests check whether each variable's hazard ratio stays constant over time. A flat, random scatter means the assumption holds. A clear trend means the effect changes over the follow-up period. If the assumption is violated for a variable, the reported hazard ratio is an average effect that may mask important time-varying behavior. The report flags violations so you know when additional modeling (time-varying coefficients) might be warranted.
What to Do With the Results
For manuscript preparation
- Use the coefficient table directly as Table 2 in your manuscript. The format follows STROBE guidelines for observational studies and CONSORT for randomized experiments.
- Export the Kaplan-Meier curve as Figure 1. Stratify by the most clinically relevant grouping variable. Include the number at risk below the x-axis.
- Report the C-index in the results section to demonstrate model discrimination. Compare it to published models for the same outcome.
For clinical quality improvement
- Identify modifiable risk factors: predictors with hazard ratios significantly above 1.0 that can be addressed through clinical intervention. If uncontrolled diabetes (HR 1.8) independently predicts 30-day readmission, intensified discharge glycemic management has evidence behind it.
- Stratify patient populations: use the model to identify high-risk subgroups that warrant closer follow-up, earlier intervention, or different care pathways.
- Quantify the impact of interventions: compare hazard ratios before and after implementing a clinical protocol change. A reduction in the readmission hazard ratio from 1.6 to 1.2 for a target population demonstrates measurable program effectiveness.
For grant applications
- Preliminary data: run survival analysis on your pilot dataset to include hazard ratios and Kaplan-Meier curves as preliminary findings. Reviewers expect to see that the proposed analysis is feasible and the effect sizes are plausible.
- Power calculations: the hazard ratios from the preliminary analysis inform the sample size calculation for the proposed study. A smaller expected effect size requires more patients.
When to Use Something Else
- Want to compare two groups without covariates: A log-rank test with Kaplan-Meier curves is simpler and requires no covariate assumptions. It answers "do these groups survive differently?" without quantifying why.
- Need a yes/no prediction only: Clinical outcome prediction with logistic regression classifies patients into risk categories without the time dimension. Use it when timing does not matter.
- Comparing treatment effects with baseline differences: Treatment efficacy comparison with ANCOVA adjusts for covariates when the outcome is a continuous score rather than time-to-event.
- PH assumption is violated: If the proportional hazards assumption fails for key variables, parametric survival models (Weibull, accelerated failure time) or time-varying coefficient models may be more appropriate.
References
- George B, Seals S, Aban I. Survival analysis and regression models. Journal of Nuclear Cardiology. 2014. PMC
- Charted: More hospitals to face readmission penalties in 2026. Advisory Board. 2025. advisory.com
Your turn
Bring your own data and the question you actually need answered.
MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai