#Commands to Practical exercise 5

 

 

# 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) Cox regression for sex:

cox.mel.a<- coxph(Surv(lifetime,status==1)~factor(sex), data=melanoma)

summary(cox.mel.a)

 

 

# b) Cox regression for ulceration:

cox.mel.b<- coxph(Surv(lifetime,status==1)~factor(ulcer), data=melanoma)

summary(cox.mel.b)

 

 

# c) Cox regression for grouped thickness:

cox.mel.c<- coxph(Surv(lifetime,status==1)~factor(grthick), data=melanoma)

summary(cox.mel.c)

 

 

# d) Cox regression with log-thickness:

cox.mel.d<- coxph(Surv(lifetime,status==1)~logthick, data=melanoma)

summary(cox.mel.d)

 

# The results are easier to interpret if we use logarithms with base 2:

cox.mel.d2<- coxph(Surv(lifetime,status==1)~log(thickn,2), data=melanoma)

summary(cox.mel.d2)

 

 

# e) Multivariate Cox regression:

cox.mel.e<- coxph(Surv(lifetime,status==1)~factor(sex)+factor(ulcer)+log(thickn,2), data=melanoma)

summary(cox.mel.e)