|
|
|
||||
|
Help the Stat Consulting Group by
giving a gift
| |||||
|
Loading
|
|||||
S-Plus Textbook Examples
Applied Survival Analysis
Chapter 3: Regression
Models for Survival Data
Sections noted by R indicate differences between R and SPLUS.
SPLUS program
R program
For chapter 3 we will primarily be using the hmohiv datasets. To input the hmohiv.csv data file in R use the following code which must be executed before running the R program:
>hmohiv <- read.csv("d:/hmohiv.csv", header=T)
Here are the SPLUS data sets: hmohiv, predictors and pred.
Table 3.1, p. 98
Note: The z test in the table is the score test. The test labeled likelihood ratio is the partial likelihood test.
age.coxph <- coxph( Surv(time,censor)~age, hmohiv, method="breslow")
summary(age.coxph)
n= 100
coef exp(coef) se(coef) z p
age 0.0814 1.08 0.0174 4.67 3e-006
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-006
Wald test = 21.8 on 1 df, p=3.02e-006
Score (logrank) test = 22 on 1 df, p=2.72e-006
Movie for table 3.1.
SPLUS does not provide confidence intervals as an option in the coxph function. One method of obtaining confidence intervals for the hazard ratio is to use the coxreg function instead. However, to use this function the predictors in the model have to be in a separate dataset so that they can be included using only one name rather than naming each predictor one by one. In order to facilitate using this function the datasets predictors and pred have been included and can be downloaded from this page. The dataset predictors include the variables age, drug and the interaction of age and drug (age*drug) and the data set pred includes just the predictors age and drug.
Here are the same results as above using the function coxreg. Note that the print function is used after coxreg instead of the summary function.
R-In R the coxreg function is not available.
age.coxph <- coxph( formula=Surv(time,censor)~age, data=hmohiv, method="breslow", )
summary(age.coxph)
age.coxreg <- coxreg(hmohiv$time, hmohiv$censor, hmohiv$age)
print(age.coxreg)
Alive Dead Deleted
20 80 0
coef exp(coef) se(coef) z p
[1,] 0.0814 1.08 0.0174 4.67 3.02e-006
exp(coef) exp(-coef) lower .95 upper .95
[1,] 1.08 0.922 1.05 1.12
Likelihood ratio test= 21.4 on 1 df, p=3.82e-006
Efficient score test = 22 on 1 df, p=2.72e-006
Table 3.2, p. 103
inter.coxph <- coxph( Surv(time,censor)~age+drug+age*drug, hmohiv, 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
Movie for table 3.2.
Using the coxreg function and the predictor data set.
R-In R the coxreg function is not available.
inter.coxreg <- coxreg(hmohiv$time, hmohiv$censor, predictors)
print(inter.coxreg) Alive Dead Deleted 20 80 0 coef exp(coef) se(coef) z p age 0.0942 1.099 0.0229 4.110 0.0000395 drug 1.1859 3.274 1.2565 0.944 0.3452566 da -0.0067 0.993 0.0337 -0.199 0.8425051 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 da 0.993 1.007 0.930 1.06 Likelihood ratio test= 35 on 3 df, p=1.21e-007 Efficient score test = 35.2 on 3 df, p=1.13e-007
Table 3.3, p. 105
main.coxph <- coxph( Surv(time,censor)~age+drug, hmohiv, 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
Movie for table 3.3.
Using the coxreg function and the data set pred.
R-In R the coxreg function is not available.
main.coxreg <- coxreg(hmohiv$time, hmohiv$censor, pred)
print(main.coxreg)
Alive Dead Deleted
20 80 0
coef exp(coef) se(coef) z p
age 0.0915 1.10 0.0185 4.95 7.39e-007
drug 0.9414 2.56 0.2555 3.68 2.29e-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
Likelihood ratio test= 35 on 2 df, p=2.53e-008
Efficient score test = 34.3 on 2 df, p=3.56e-008
Table 3.4, p. 108
Note: SPLUS does have a method="exact" option but there were problems when using it.
Note2: The coxph function uses the Efron method for handling ties as a default.
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, hmohiv)
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
<output omitted>
Movie for table 3.4.
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