Showing posts with label survival analysis. Show all posts
Showing posts with label survival analysis. Show all posts

Sunday, March 4, 2012

Estimating Cox Model parameters with and without coxph function from survival package


Reading data


library(survival)
data(veteran)
time.var <- veteran[,3] 
status.var <- veteran[,4] 
covariate.matrix <- veteran[,c(1,5:8)] 
covariate.names <- names(veteran[,c(1,5:8)])
data <- cbind.data.frame(time.var,status.var,covariate.matrix)



Kaplan-Meier and Nelson-Aalen estimates with and without survfit function from survival package

Data reading:


rm(list=ls(all=TRUE)) # wipe out everything else
require(survival)
data = aml[aml$x == "Maintained",]
data