# NOT RUN {
# }
# NOT RUN {
## computation times is roughly 10 seconds
##-------------Without competing risks-------------------
library(survival)
data(pbc)
head(pbc)
pbc<-pbc[!is.na(pbc$trt),] # select only randomised subjects
pbc$status<-as.numeric(pbc$status==2) # create event indicator: 1 for death, 0 for censored
# we evaluate bilirubin as a prognostic biomarker for death.
ROC.bili<-timeROC(T=pbc$time,
delta=pbc$status,marker=pbc$bili,
cause=1,weighting="marginal",
times=quantile(pbc$time,probs=seq(0.2,0.8,0.02)),
iid=TRUE)
ROC.bili
# we evaluate bilirubin as a prognostic biomarker for death.
ROC.albumin<-timeROC(T=pbc$time,
delta=pbc$status,marker=-pbc$albumin,
cause=1,weighting="marginal",
times=quantile(pbc$time,probs=seq(0.2,0.8,0.02)),
iid=TRUE)
ROC.albumin
# plot AUC curve for albumin only with pointwise confidence intervals
# and simultaneous confidence bands
plotAUCcurve(ROC.albumin,conf.int=TRUE,conf.band=TRUE)
# plot AUC curve for albumin and bilirunbin with pointwise confidence intervals
plotAUCcurve(ROC.albumin,conf.int=TRUE,col="red")
plotAUCcurve(ROC.bili,conf.int=TRUE,col="blue",add=TRUE)
legend("bottomright",c("albumin","bilirunbin"),col=c("red","blue"),lty=1,lwd=2)
##-------------With competing risks-------------------
data(Melano)
head(Melano)
# Evaluate tumor thickness as a prognostic biomarker for
# death from malignant melanoma.
ROC.thick<-timeROC(T=Melano$time,delta=Melano$status,
marker=Melano$thick,cause=1,
times=quantile(Melano$time,probs=seq(0.2,0.8,0.01)),
iid=TRUE)
ROC.thick
# plot AUC curve for tumor thickness with pointwise confidence intervals
# and simultaneous confidence bands
plotAUCcurve(ROC.thick,FP=2,conf.int=TRUE,conf.band=TRUE)
# }
Run the code above in your browser using DataLab