Model survival on several predictors at once, and report hazard ratios.
Your browser does not support embedded video. Download the video (MP4).
:::
Everything in the video, ready to copy:
# Cox proportional hazards library(survival) library(gtsummary) # Fit a Cox model (lung cancer data) cx <- coxph(Surv(time, status) ~ age + sex + ph.ecog, data = lung) # Hazard ratios with 95% CI tbl_regression(cx, exponentiate = TRUE) # Check the proportional-hazards assumption cox.zph(cx)
Download this R script · ▶ Practice in the playground
When to use it. Use it to adjust survival for multiple covariates. A hazard ratio is only valid if the proportional-hazards assumption holds — always test it with cox.zph().
Read Cox proportional hazards in R.
Next: Diagnostic Test Accuracy →