whas.table <- read.table('http://www.stanford.edu/class/stats262/data/whas.csv', sep=',', header=T) whas.table <- whas.table[(whas.table$yrgrp == '1975 & 1978'),] attach(whas.table) library(survival) # Using AIC whas.AIC <- step(coxph(Surv(lenfol, (fstat == 'Dead')) ~ 1), list(lower=~1, upper=~age+sex+cpk+sho+chf+lenstay), direction='both') # Using BIC whas.BIC <- step(coxph(Surv(lenfol, (fstat == 'Dead')) ~ 1), list(lower=~1, upper=~age+sex+cpk+sho+chf+lenstay), direction='both', k=log(length(lenfol)))