Home > Teaching > Tutorials > Survival Analysis in R
Survival Analysis in R
During Biostat M215, a survival analysis course, I wrote an R tutorial for survival analysis as my final project:
The older version of the guide is also available for those who are still enjoying much earlier versions of the survival package.
The tutorial itself would be well supplemented by the book Survival Analysis: Techniques for Censored and Truncated Data by Klein and Moeschberger (Amazon.com book version, Amazon Kindle version*, Barnes and Noble), which was the text used for the course I took.
In the tutorial, I assume the reader has some vague knowledge of R and is comfortable with the survival analysis material discussed. In the tutorial I offer a brief run-through of the necessities to run the code. For the survival analysis material, there is a brief review of the topics implemented (although this will not be useful to someone who has no background work in survival analysis).
Data sets used in the tutorial are available in the OIsurv and KMsurv R packages.
Another resource that goes into greater depth on Cox PH models is written by John Fox and may be found here.
Some additional functions have been written to supplement the guide that may be useful:
conf.bands() :: function description
local.coxph.test() :: function description
time.dep.coxph() (DEPRECIATED) :: function description
df.cp() with example :: See .R file for an example and explanation of the arguments. This function replaces time.dep.coxph(). Thank you Beau Benjamin Bruce, who has kindly provided this much-improved function.
The functions above have been checked under several cases, however, they come with ABSOLUTELY NO WARRANTY. Please let me know if you find any bugs, typos, etc.