R-help to exercise 24
# Read the data into a dataframe:
melanom=read.table("http://www.uio.no/studier/emner/matnat/math/STK4900/v11/melanoma.dat",header=T)
# Attach the R-library for survival analysis (if you have not already done so):
library(survival)
# QUESTION a
# Commands:
fit.sex=survfit(Surv(lifetime,status==1)~sex, data=melanom)
plot(fit.sex, lty=1:2, mark.time=F)
survdiff(Surv(lifetime,status==1)~sex, data=melanom)
# QUESTIONS b and c are done by similar commands
# QUESTIONS d and e
# Commands for sex
coxfit.sex=coxph(Surv(lifetime,status==1)~factor(sex),data=melanom)
summary(coxfit.sex)
# The other covariates in question d are done by similar commands, and so is question e