library(survival)
justices <- read.csv("http://data.princeton.edu/pop509/justices2.csv")
PREDS = c("age", "year")
m = coxph(Surv(tenure, event == 1) ~ age + year, data = justices)
summary(m)
exp(coef(m)[1])
exp(confint(m,level=(1-0.05/1))[1,])
DVMOD <- function(PREDS, data){
t <- coxph(paste0("Surv(tenure, event == 1) ~ "), PREDS + number + name, data = data)
return((c(PREDS, coef(t)[1], confint(t)[1,])))
}
all_models <- lapply(PREDS,DVMOD, PREDS = PREDS, data=justices)
I wish to run separate coxph model for each variable in PREDS and then store the name of that variable with its hazard ratio and confidence bands.