#The commands below assume that the melanoma data set has been stored

# in the dataframe "melanoma", that the survival library has been attached

# and that "sex" and "ulcer" are defined as factors

# (cf. the R commands to practical exercise 3)

 

# In practical exercise 4 we arrived at the model:

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

 

#In order to estimate/plot ?the survival for an individual with given values

#of the covariates, we may use the coxph-object "cox.mel" as an input

#to the survfit-command.

 

#We illustrate the approach by plotting the estimated survival for patients

#with covariates

# (i) ulcer=2, thickn=2

# (ii) ulcer=1, thickn=2

# (iii) ulcer=2, thick=5

# (iv) ulcer=1, thick=5

cox.mel22<-survfit(cox.mel,newdata=data.frame(ulcer=2,thickn=2),conf.type="plain")

cox.mel12<-survfit(cox.mel,newdata=data.frame(ulcer=1,thickn=2),conf.type="plain")

cox.mel25<-survfit(cox.mel,newdata=data.frame(ulcer=2,thickn=5),conf.type="plain")

cox.mel15<-survfit(cox.mel,newdata=data.frame(ulcer=1,thickn=5),conf.type="plain")

plot(cox.mel22,conf.int=F,main="Estimated survival curves")
lines(cox.mel12,lty=2)
lines(cox.mel25,lty=3)
lines(cox.mel15,lty=4)