R-help to exercise 15 in BSS

 

 

# The data are from a old study of children with leukemia.

# The children were treated so that they had no symptoms (one say that they are in remission).

# They were then given an active treatment ("Drug") to keep the symptoms from coming back or placebo ("Control").

# Time until the symptoms came back (called relapse) were measured.

# For some children the symptoms had not come back at the end of the study. These give rise to censored observations.

 

 

# Read the data into a dataframe and inspect the data:

gehan<-read.table("http://www.uio.no/studier/emner/matnat/math/STK4900/v07/annet/gehan.dat", header=T)

gehan

 

# Check that the data correspond to those given in the exercise.

# "time" is time in weeks to relapse or censoring

# "cens" is 1 for relapse and 0 for censoring

# "treat" is 1 for "Control" and 2 for "Drug"

 

 

# Attach the dataframe

attach(gehan)

 

 

# Attach the R-library for survival analysis:

library(survival)

 

 

# QUESTION 1 (and 3)

 

# Compute Kaplan-Meier estimates for the two groups (without confidence intervals)
fit.1<-survfit(Surv(time,cens)~treat, conf.type="none")
summary(fit.1)
 
# Make sure you understand what the output tells!
 
 
# Plot the Kaplan-Meier estimates:
plot(fit.1,lty=1:2)
 
# Interpret the plots.
# Read from the plots (approximately) what is the median time to relapse for the two groups
# Check the results by giving the command "print(fit.1)" 
 
 

# QUESTION 2

 
# Compute Kaplan-Meier estimates for the two groups with confidence intervals
# (the default confidence interval in R is not a good choice, so we make an explicit choice of the type of confidence interval) 
fit.2<-survfit(Surv(time,cens)~treat, conf.type="plain")
summary(fit.2)
plot(fit.2, conf.int=T, lty=1:2)
 
# Interpret the output and the plot.
 
 
# We then look at the additional questions given at the course web-page
 
# QUESTION 4
 
# Log-rank test for difference between the groups:
survdiff(Surv(time,cens)~treat)
 
# What does the output tell you?
 
 
# QUESTION 5
 
# Cox regresion with treatment group as covariate:
fit.5<-coxph(Surv(time,cens)~factor(treat))
summary(fit.5)

 

# Interpret the results!