Adjusted survival curves
Cox-predicted time to patent grant at four levels of relatedness, other covariates at their mean.

A hazard ratio is hard to feel; a survival curve is not. Here a fitted Cox proportional hazards model is used to predict the whole curve for hypothetical applications that differ only in their relatedness to the applicant's earlier patents, while every other covariate is fixed at its sample mean. The horizontal spread between the curves is the effect of relatedness translated into months of waiting for a grant.
The setting is Vorreuther & Warin (2021, Data in Brief), a dataset on patent
relatedness and velocity in the Chinese pharmaceutical industry. The data here
are simulated for illustration and are not the paper's data or results: 400
pharmaceutical patent applications, with relatedness measured as a Jaccard
similarity between 0 and 1. The model is fitted with lifelines.CoxPHFitter on
all four covariates and the curves come from predict_survival_function(); the
observed Kaplan–Meier curve of the whole sample is drawn in grey for reference.
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from lifelines import CoxPHFitter, KaplanMeierFitter
# Simulated data, set in the context of Vorreuther & Warin (2021) [vorreuther2021]
# Data: months from filing to grant of 400 patent applications (shared generator)
rng = np.random.default_rng(2021)
n = 400
df = pd.DataFrame({"foreign": rng.integers(0, 2, n), "university": (rng.random(n) < 0.25).astype(int),
"claims": rng.poisson(12, n), "relatedness": rng.beta(2, 4, n).round(2)})
lp = 0.6 * df.foreign - 0.04 * (df.claims - 12) + 2.0 * (df.relatedness - 0.33) - 0.35 * df.university
grant = 40 * rng.weibull(2, n) * np.exp(-lp / 2) # Weibull PH: higher lp, faster grant
cens = rng.uniform(24, 96, n) # end of observation window
df["months"], df["granted"] = np.minimum(grant, cens).round(1), (grant <= cens).astype(int)
cph = CoxPHFitter().fit(df, duration_col="months", event_col="granted")
# Hypothetical applications: everything at the mean, relatedness varies
levels = [0.1, 0.3, 0.5, 0.7]
profiles = pd.DataFrame([df.drop(columns=["months", "granted"]).mean()] * len(levels))
profiles["relatedness"] = levels
surv = cph.predict_survival_function(profiles, times=np.arange(0, 73))
colors = plt.cm.Blues(np.linspace(0.4, 0.95, len(levels)))
fig, ax = plt.subplots(figsize=(8, 5))
# Observed Kaplan–Meier curve of the whole sample, for reference
km = KaplanMeierFitter().fit(df.months, df.granted)
ax.step(km.survival_function_.index, km.survival_function_.iloc[:, 0], where="post",
color="#AEAEB2", lw=1.5, ls="--", label=f"Observed Kaplan–Meier, all {n} applications")
# Model-predicted curves, with the predicted median time to grant in the legend
for col, r, c in zip(surv.columns, levels, colors):
s = surv[col]
med = s.index[(s <= 0.5).argmax()]
ax.step(s.index, s, where="post", color=c, lw=2.2,
label=f"relatedness = {r:.1f} · median {med:.0f} months")
ax.axhline(0.5, color="#C7C7CC", lw=1, zorder=0)
ax.legend(loc="upper right")
hr = np.exp(0.1 * cph.params_["relatedness"])
lo, hi = np.exp(0.1 * cph.confidence_intervals_.loc["relatedness"])
p = cph.summary.loc["relatedness", "p"]
p_txt = "p < .001" if p < 0.001 else f"p = {p:.3f}"
ax.set(xlim=(0, 72), ylim=(0, 1.01), xticks=range(0, 73, 12),
xlabel="Months since filing", ylabel="Predicted probability still pending")
ax.yaxis.set_major_formatter(plt.matplotlib.ticker.PercentFormatter(1, decimals=0))
ax.set_title("Applications related to earlier patents are granted sooner, all else equal", pad=26)
ax.text(0, 1.02, f"Cox PH, other covariates at their mean · HR per 0.1 relatedness = "
f"{hr:.2f} [{lo:.2f}, {hi:.2f}], {p_txt} · n = {n} (simulated)",
transform=ax.transAxes, fontsize=9.5, color="#6E6E73")
plt.show()
Figures use the optional PyStatlas style: add plt.style.use("pystatlas.mplstyle") to match the look exactly.
Data source
- Simulated data. Simulated data with a fixed random seed, created for this example.
No real respondents, documents or measurements: the numbers only illustrate how the chart and its statistics work. - Vorreuther & Warin (2021), patent velocity in China's pharmaceutical industry. Vorreuther, C. M., & Warin, T. (2021). Patent relatedness and velocity in the Chinese pharmaceutical industry: A dataset of Jaccard similarities. Data in Brief, 35, 106814. https://doi.org/10.1016/j.dib.2021.106814
The example is set in the context of this paper; unless its description says otherwise, the numbers are simulated and are not the paper's data or results.
The examples illustrate statistical methods. Their numbers are simulated unless an entry says otherwise, and their titles describe what each figure shows in these simulated data — not findings of the cited papers, nor the author's position on the substantive question. For results, context and data, rely on the papers cited here.
How to cite
PyStatlas is created and maintained by Thierry Warin. If it helped your work, please cite it.
Warin, T. (2026). Adjusted survival curves. In PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences (Version 1.1.0) [Computer software]. https://warin.ca/pystatlas/survival/adjusted-survival/
@misc{warin2026statlas,
author = {Warin, Thierry},
title = {PyStatlas: A Python Gallery of Statistical Graphics for the Social Sciences},
year = {2026},
version = {1.1.0},
howpublished = {\url{https://warin.ca/pystatlas/}},
note = {Source code: https://github.com/warint/pystatlas}
}More in Survival analysis
Kaplan–Meier curves
Time from patent filing to grant, domestic vs foreign applicants, with log-rank test and risk table.
survminer::ggsurvplot(risk.table = TRUE)Cox hazard ratios
Forest plot of a Cox model of time to patent grant, with HR, 95% CI and p-values.
survminer::ggforest()Cumulative hazard
Nelson–Aalen cumulative hazard of a drug's launch, with 95% bands, in four market groups.
survminer::ggsurvplot(fun = "cumhaz")