# Kaplan-Meier estimates for the leukemia data from Exercise 3.1

 

# Read data (directly from web-page):

leukemia=read.table("http://www.math.uio.no/~borgan/abg-2008/data/leukemia.txt", header=T)

 

# Attach the library with commands for survival analysis:

library(survival)

 

# Compute Kaplan-Meier estimates:

fit.leuk=survfit(Surv(time,status)~treat, data=leukemia, conf.type="plain")

 

# Output summary and make plot:

print(fit.leuk)

summary(fit.leuk)

 

# Make plot without and with standard ("plain") confidence intervals:

plot(fit.leuk, mark.time=F, lty=c(1,2), xlab="Weeks")

plot(fit.leuk, conf.int=T, mark.time=F, lty=c(1,2), xlab="Weeks")