Appendix D

Survival Packages in R

D.1 Introduction

The basic package for survival analysis in R is the survival package (Therneau & Grambsch 2000). It is one of the so-called recommended packages in R, which means that it is automatically installed when R itself is installed. You must, however, load it in a running R environment before you can use it.

There are a few other R packages devoted to survival and event history analysis. Besides eha, more or less the theme of this book, there are timereg and cmprsk. For a detailed explanation of how to use these packages, see their documentations in R.

D.2 eha

The package eha is written and maintained by the author of this book. It has a long history as a stand-alone program (written in FORTRAN, Turbo Pascal, and C during different time periods) in the “pre R” era. When I was aware of the existence of the R environment (in the mid-nineties), it was an easy decision to convert it into an R package.

Today, the function coxreg in eha rests to a large part on the function coxph in the survival package, but it has some features of its own, notably

Discrete time Cox regression With the option method = ‘ml’ a discrete-time Cox regression is performed with a discrete hazard atom at each observed event time. This is equivalent to a logistic regression with the cloglog link.

Sampling of risk sets The weird bootstrap (Andersen et al. 1993) is implemented in coxreg. It is activated by setting the argument boot equal to the desired number of bootstrap replicates.

Time-dependent case weights

Other features of the eha package are listed below.

Parametric proportional hazards models The common parametricmodels in other packages are of the AFT type. While there is a function in eha for these models (aftreg), the function phreg fits proportional hazards parametric models. Especially worth mentioning is the implementation of the piecewise constant hazards (pch) model.

Lexis diagram cuts With the aid of the two functions age.window and cal.window it is easy to make vertical and horizontal cuts in the Lexis diagram. The function survSplit

Tools for communal covariates The main tool is the function make.communal, that takes an external time series (think weather, economy, epidemics, etc.) and turns it into a time-dependent covariate.

For a presentation of the most important functions in eha, see Appendix C.

D.3 survival

The survival package is a recommended one, and it does not need a separate installation. It contains all the basic features that a package on survival analysis should have, and more. The main important functions are listed here:

coxph This is the main function for Cox regression. It has a number of features; time-dependent variables and strata, multiple events per subject, jackknife-type variance estimators for clustered data, and frailty models. Allows left-truncated data. Fast and reliable numerical algorithms.

survfit Takes care of the presentation and “afterwork” of a fit to a proportional hazards model or a accelerated failure time model, including plotting and printing.

survreg Fits parametric accelerated failure time models. Allows right and interval censoring, but not left truncation.

cox.zph For testing of the proportionality assumption of fit from a call to coxph.

aareg Fits Aalen’s additive hazards model (Aalen 1989, Aalen 1993) to survival regression data.

D.4 Other Packages

D.4.1 coxme

The package coxme (Therneau 2011) analyzes frailty models in Cox regression. Its author, Terry Therneau, is the author of the survival package, which also can fit frailty models. According to the author, coxme is the preferred package for frailty models.

D.4.2 timereg

The timereg package is developed by Martinussen & Scheike (2006). A key feature of the package (and the cited book) is extensions of the Cox model, especially models with time-varying effects of covariates. Aalen’s additive hazards model is in focus. Resampling is frequently used for the calculation of p-values.

Recently, the package has been promoted for being able to analyze competing risks models (Scheike & Zhang 2011).

D.4.3 cmprsk

This is a competing risks package (Gray 2011), based on work by Gray (1988) and Fine & Gray (1999).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset