OpenIntro Statistics
Survival Analysis in R

The PDF below provides a guide to survival analysis in R using the survival package, supplemented by the KMsurv and OIsurv packages for additional data sets and functions.

Survival Analysis in R (PDF) Full set of code used in guide

Prerequisites: basic knowledge of R, comfort with the survival analysis material discussed.

This guide would be a useful supplement to the textbook Survival Analysis: Techniques for Censored and Truncated Data by Klein and Moeschberger (Amazon, Barnes and Noble). There is no association between this textbook or its authors and OpenIntro.

Supplemental code for Cox PH, time-dependent covariates

Users who are especially interested in the application of Cox PH models using time-dependent covariates may be interested in one additional function, which has been kindly provided by Beau Benjamin Bruce.

Code containing df.cp function