# import and attach the data example
data(dataDIVAT)
# A subgroup analysis to reduce the time needed for this exemple
dataDIVAT <- dataDIVAT[1:400,]
# cut-off values definition (choose more values in prectice)
age.cut <- quantile(dataDIVAT$ageR, probs=seq(0.0, 1.0, by=0.2))
# the ROC curve (with the knn correction) to predict the all-cause
# mortality up to the 3000 days
roc1 <- allcause.ROCt(times=dataDIVAT$death.time,
failures=dataDIVAT$death, variable=dataDIVAT$ageR,
pro.time=3000, cut.off=age.cut, lambda=0.05,
knn=TRUE)
# the sensibilities and specificities associated with the cut off values
roc1$table
# the ROC curve (without the knn correction) to predict the all-cause
# mortality up to the 3000 days
roc2 <- allcause.ROCt(times=dataDIVAT$death.time,
failures=dataDIVAT$death, variable=dataDIVAT$ageR,
pro.time=3000, cut.off=age.cut, lambda=NULL,
knn=FALSE)
# the traditional ROC graph
plot(c(1,1-roc1$table$sp,0), c(1, roc1$table$se, 0), ylim=c(0,1),
xlim=c(0,1), ylab="sensitivity", xlab="1-specificity",
type="l", col=2, lty=1, lwd=2)
lines(c(1,1-roc2$table$sp,0), c(1,roc2$table$se,0),
type="l", col=4, lty=2, lwd=2)
abline(c(0,0), c(1,1), lty=2)
legend("bottomright", c(
paste("With knn, (AUC=", round(roc1$auc, 2), ")", sep=""),
paste("Without knn, (AUC=", round(roc2$auc, 2), ")", sep="")),
lty=1:2, lwd=c(2,2), col=c(2,4))Run the code above in your browser using DataLab