#The commands below assume that the melanoma data set has
been stored
# in the dataframe "melanoma" and that the
survival library has been attached
# (cf. the R commands to practical exercise 3)
# Define sex as a categorical covariate
# (This is not really necessary for a categorical covariate with only two levels,
# but it is good practice to do so.)
melanoma$sex<-factor(melanoma$sex)
# Fit a univariate Cox regression model for gender and look at the results:
cox.mel<- coxph(Surv(lifetime,status==1)~sex, data=melanoma)
summary(cox.mel)
# Fit a univariate Cox regression model for tumor thickness and look at the results:
cox.mel<- coxph(Surv(lifetime,status==1)~ thickn, data=melanoma)
summary(cox.mel)
#It may be more appropriate to use the logartimhm (with base 2) of tumor thickness:
cox.mel<- coxph(Surv(lifetime,status==1)~ log(thickn,2), data=melanoma)
summary(cox.mel)
# Fit bivariate Cox regression with gender and log-thickness:
cox.mel<- coxph(Surv(lifetime,status==1)~sex+log(thickn,2), data=melanoma)
summary(cox.mel)