Time-to-event data — the backbone of clinical outcomes research.
Your browser does not support embedded video. Download the video (MP4).
:::
Everything in the video, ready to copy:
# Kaplan-Meier survival curves library(survival) # Survival by sex (lung cancer data) fit <- survfit(Surv(time, status) ~ sex, data = lung) fit # The survival curve plot(fit, col = c("#2f6fed", "#17a2b8"), lwd = 3, xlab = "Days", ylab = "Survival probability") legend("topright", c("Male", "Female"), col = c("#2f6fed", "#17a2b8"), lwd = 3) # Log-rank test: do the groups differ? survdiff(Surv(time, status) ~ sex, data = lung)
Download this R script · ▶ Practice in the playground
When to use it. Use it to estimate and compare survival over time between groups. The log-rank test asks whether the curves differ; report median survival per group.
Read publication-quality Kaplan-Meier curves.
Next: Cox Proportional Hazards →