larynx<-as.data.frame( scan("larynx.dat", what=list(stage=0,time=0,age=0,year=0,status=0))) larynx$year<-larynx$year-74 stages23<-larynx[(larynx$stage==2)|(larynx$stage==3),] library(survival) cat('Larynx Cancer Survival Stages 2&3 Testing Stage\n') survdiff(Surv(time,status)~factor(stage),data=stages23) # Now fit proportional hazards model. Use summary to # give the score statistic as well. cat('Larynx Cancer Survival Stages 2&3 Fitting Stage\n') # Exact below corresponds to discrete in SAS summary(coxph(Surv(time,status)~factor(stage),data=stages23, method="exact")) cat('Larynx Cancer Survival Stages 2&3 Fitting Stage\n') summary(coxph(Surv(time,status)~factor(stage),data=stages23, method="breslow")) cat('Larynx Cancer Survival Stages 2&3 Fitting Stage\n') # Efron is the default below. summary(coxph(Surv(time,status)~factor(stage),data=stages23, method="efron")) cat('Larynx Cancer Survival All Stages Fitting Stage\n') coxph(Surv(time,status)~factor(stage),data=larynx) cat('Larynx Cancer Survival All Stages Fitting Stage, Age\n') coxph(Surv(time,status)~factor(stage)+age,data=larynx) cat('Using stage as quant. instead of categorical\n') coxph(Surv(time,status)~stage+age+year,data=larynx) cat('An alternate parameterization of stage\n') coxph(Surv(time,status)~factor(stage,levels=c(4,3,2,1))+age, data=larynx) cat('Fitting all stages with age interaction\n') coxph(Surv(time,status)~factor(stage)*age,data=larynx)