UCLA Academic Technology Services HomeServicesClassesContactJobs
Search

R Textbook Examples
Applied Survival Analysis
Chapter 3: Regression Models for Survival Data

The R packages needed for this chapter are the survival package. We currently use R 2.0.1 patched version. You may want to make sure that packages on your local machine are up to date. You can perform update in R using update.packages() function.


Table 1.1 on page 98 using data set hmohiv.

library(survival)
rm(list=ls())
hmohiv<-read.table("http://www.ats.ucla.edu/stat/R/examples/asa/hmohiv.csv", sep=",", header = TRUE) 
attach(hmohiv)
age.coxph <- coxph( Surv(time,censor)~age, method="breslow")
summary(age.coxph)

  n= 100 
      coef exp(coef) se(coef)    z     p
age 0.0814      1.08   0.0174 4.67 3e-06

    exp(coef) exp(-coef) lower .95 upper .95
age      1.08      0.922      1.05      1.12

Rsquare= 0.192   (max possible= 0.997 )
Likelihood ratio test= 21.4  on 1 df,   p=3.82e-06
Wald test            = 21.8  on 1 df,   p=3.03e-06
Score (logrank) test = 22    on 1 df,   p=2.72e-06

Table 3.2 on page 103 using data set hmohiv created in the previous example.

inter.coxph <- coxph( Surv(time,censor)~age+drug+age*drug, method="breslow")
summary(inter.coxph)

 n= 100 

            coef exp(coef) se(coef)      z       p 
     age  0.0942     1.099   0.0229  4.110 0.00004
    drug  1.1859     3.274   1.2565  0.944 0.35000
age:drug -0.0067     0.993   0.0337 -0.199 0.84000

         exp(coef) exp(-coef) lower .95 upper .95 
     age     1.099      0.910     1.051      1.15
    drug     3.274      0.305     0.279     38.42
age:drug     0.993      1.007     0.930      1.06

Rsquare= 0.295   (max possible= 0.997 )
Likelihood ratio test= 35    on 3 df,   p=1.21e-007
Wald test            = 32.2  on 3 df,   p=4.83e-007
Score (logrank) test = 35.2  on 3 df,   p=1.13e-007

Table 3.3 on page 105 using hmohiv.

main.coxph <- coxph( Surv(time,censor)~age+drug, method="breslow")
summary(main.coxph)

  n= 100 

       coef exp(coef) se(coef)    z        p 
 age 0.0915      1.10   0.0185 4.95 7.4e-007
drug 0.9414      2.56   0.2555 3.68 2.3e-004

     exp(coef) exp(-coef) lower .95 upper .95 
 age      1.10      0.913      1.06      1.14
drug      2.56      0.390      1.55      4.23

Rsquare= 0.295   (max possible= 0.997 )
Likelihood ratio test= 35    on 2 df,   p=2.53e-008
Wald test            = 32.5  on 2 df,   p=8.76e-008
Score (logrank) test = 34.3  on 2 df,   p=3.56e-008

Table 3.4 on page 108 using different methods on data set hmohiv. Notice that although that coxph allows the "exact" option. But this example has a problem with convergence. We therefore do not have the output here.

breslow.coxph <- coxph( Surv(time,censor)~age+drug, hmohiv, method="breslow")
summary(breslow.coxph)

  n= 100 

       coef exp(coef) se(coef)    z        p 
 age 0.0915      1.10   0.0185 4.95 7.4e-007
drug 0.9414      2.56   0.2555 3.68 2.3e-004

<output omitted>

efron.coxph <- coxph( Surv(time,censor)~age+drug, method="efron")
summary(efron.coxph)

  n= 100 

       coef exp(coef) se(coef)    z        p 
 age 0.0971      1.10   0.0186 5.21 1.9e-007
drug 1.0167      2.76   0.2562 3.97 7.2e-005


How to cite this page

Report an error on this page

UCLA Researchers are invited to our Statistical Consulting Services
We recommend others to our list of Other Resources for Statistical Computing Help
These pages are Copyrighted (c) by UCLA Academic Technology Services


The content of this web site should not be construed as an endorsement of any particular web site, book, or software product by the University of California