Chapter 7 Survival Analysis

In this chapter, you will learn how to:

  • Identify a time-to-event outcome;
  • Identify types and mechanisms of censoring;
  • Interpret the survival and hazard functions;
  • Use the Kaplan-Meier method to estimate the survival function;
  • Use the log-rank test to compare survival between groups;
  • Visualize the Kaplan-Meier estimate of the survival function;
  • Visualize the estimated hazard function;
  • Fit a Cox proportional hazards regression model, including the following:
    • Write and interpret the Cox regression equation;
    • Estimate unadjusted and adjusted hazard ratios;
    • Estimate the probability that an event has not yet occurred as of a given time;
    • Estimate the hazard of an event relative to a reference group;
    • Visualize the Cox regression estimate of the survival function;
    • Test interactions between predictors;
    • Incorporate time-varying predictors;
    • Check the proportional hazards assumption;
    • Allow non-proportional hazards using a time interaction or stratification;
    • Check the linearity assumption, examine outliers, and identify influential observations; and
    • Appropriately summarize the methods and results.

To use the code in this chapter, first load the tidyverse and survival (Terry M. Therneau and Patricia M. Grambsch 2000; Therneau 2023) packages.



Terry M. Therneau, and Patricia M. Grambsch. 2000. Modeling Survival Data: Extending the Cox Model. New York: Springer.
Therneau, Terry M. 2023. Survival: Survival Analysis.