# R code to fit the Cox model to data from the # VA lung cancer trial of 137 male patients # with inoperable lung cancer. This code is # posted as # vacoxph.R # Variables # Treatment: 1=standard, 2=test (chemotherapy) # Celltype: 1=squamous, 2=smallcell, # 3=adeno, 4=large # Survival in days # Status: 1=dead, 0=censored # Karnofsky score # Months from Diagnosis # Age in years # Prior therapy: 0=no, 10=yes # Enter the data into a data frame. va <- read.table("c:/stat565/data/va.dat", header=F, col.names=c("rx", "cellt", "time", "status", "karno", "months", "age", "priorrx")) va$rx <- va$rx-1 va$priorrx <- va$priorrx/10; va$celltf<-as.factor(va$cellt) va library(survival) options(contrasts=c("contr.treatment", "contr.poly")) vafit <- coxph(Surv(time, status) ~ rx+celltf+karno +months + age + priorrx, data = va, x=T, y=T, robust=T, method="efron", singular.ok=T) summary(vafit) names(vafit) vafit$x vafit$coef vafit$var # Model selection step(vafit, direction="both", trace=1, steps=1000, k=2)