#Commands to practical exercise 4

 

# The commands below assume that:?

#?? (i)? the melanoma data set has been stored in the dataframe "melanoma"

#?? (ii) the survival library has been attached

#?? (iii) "sex" and "ulcer" have both been defined as factors

#???????? (this is no really needed for binary categorical variables,'

#????????? but it is good practice to do so)

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

 

 

# a)

 

# First we fit univariate Cox regressions for the two binary covariates:

 

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

summary(cox.mel)

 

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

summary(cox.mel)

 

# For the numeric covariates, we need to decide whether they should

# enter the Cox regression as coded on the data file, or whether they

# should be transformed or converted to categorical covariates (if a

# useful transformation is hard to find).

 

# We do not address this question in a systematic manner here, but note

# that the Nelson-Aalen plots from practical exercise 3 indicate that

# tumor thickness should be log-transformed (for ease of interpretation

# using base 2 logs), while age can be entered as coded.

 

 

# Then we fit univariate Cox regressions for log2-thickness and age

 

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

summary(cox.mel)

 

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

summary(cox.mel)

 

 

 

#b)

 

# First fit a multivariate Cox regression with all four covariates:

 

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

summary(cox.mel)

 

# Omit gender (which has largest P value)

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

summary(cox.mel)

 

# Omit age (which has largest P value among the remaining)

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

summary(cox.mel)

 

# We end up with a model with log2-thickness and ulceration

# This model ought to be checked for proportional hazards

# and possible interaction(s), but that is a theme for later lectures

# and exercises