#Commands to Practical exercise 3

 

 

# Read the data into R and attach the survival library

melanoma=read.table("http://www.uio.no/studier/emner/matnat/math/STK4080/h08/computing/melanoma.txt", header=T)

library(survival)

 

 

# a) Kaplan-Meier estimates and plots for males and females:

 

fit.mel.a=survfit(Surv(lifetime,status==1)~sex, data=melanoma, conf.type="plain")

plot(fit.mel.a, mark.time=F, lty=c(1,2), xlim=c(0,10), xlab="Years after operation", main="Sex")

legend(0.5,0.15,legend=c("Females","Males"),lty=c(1,2))

summary(fit.mel.a)

 

# b) Kaplan-Meier estimates and plots for ulceration:

 

fit.mel.b=survfit(Surv(lifetime,status==1)~ulcer, data=melanoma, conf.type="plain")

plot(fit.mel.b, mark.time=F, lty=c(1,2), xlim=c(0,10), xlab="Years after operation", main="Ulceration")

legend(0.5,0.15,legend=c("Present","Absent"),lty=c(1,2))

summary(fit.mel.b)

 

 

# c) Kaplan-Meier estimates and plots for thickness groups:

 

fit.mel.c=survfit(Surv(lifetime,status==1)~grthick, data=melanoma, conf.type="plain")

plot(fit.mel.c, mark.time=F, lty=c(1,2,3), xlim=c(0,10), xlab="Years after operation", main="Ulceration")

legend(0.5,0.20,legend=c("0-1 mm","2-5 mm","5+ mm"),lty=c(1,2,3))

summary(fit.mel.c)