R-TUTORIAL FOR THE KAPLAN-MEIER ESTIMATOR This tutorial is based on "Practical exercise 2" in STK4080 2014. In the tutorial we will use the Kaplan-Meier estimator to study survival for the melanoma patients. As described in the tutorial for the Nelson-Aalen estimator, you should first load the library 'survival' and then read the data into R by the command: path="http://www.uio.no/studier/emner/matnat/math/STK4080/h14/melanoma.txt" melanoma=read.table(path,header=T) -------------- We consider the computation of the Kaplan-Meier estimates for the mortality from melanoma treating death from other causes as censoring. If we consider all patients, this may be performed by the command (you need to load the survival-library) fit.mel0=survfit(Surv(lifetime,status==1)~1,data=melanoma,conf.type="plain") We may then plot the Kaplan-Meier estimate with standard confidence limits by plot(fit.mel0, mark.time=F, xlab="Years after surgery") The following command gives a summary of the results: summary(fit.mel0) ------------ We may then compute Kaplan-Meier estimates for females and males: fit.sex=survfit(Surv(lifetime,status==1)~sex,data=melanoma,conf.type="plain") A plot of the estimates is obtained by: plot(fit.sex, mark.time=F, xlab="Years after surgery",lty=1:2) legend("bottomleft",c("females","males"),lty=1:2) We may use the summary command to obtain the estimated survival with confidence intervals: summary(fit.sex) From the summary we may read off an estimate for the lower quartile with confidence limits, cf. section 3.2.3 and exercise 3.8 in the ABG-book. For females the lower quartile becomes 8.33 years with 95% confidence limits from 5.30 years and upwards (no upper limit can be obtained) For males the lower quartile becomes 3.36 years with 95% confidence limits from 2.17 to 5.76 years. We may also obtain the lower quartile with confidence limits from the command: quantile(fit.sex,probs=0.25) ------------------ We can similarly make Kaplan-Meier plots for patients with ulceration present and absent, and estimate (if possible) the quantiles. ----------------- Finally, we can make Kaplan-Meier plots for the three thickness groups 0-1 mm, 2-5 mm, 5+ mm, and consider the estimation of quantiles. --------------------