1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| coxmf1 <- paste0("Surv(time, status==1)~", paste(colnames(df)[1:11], collapse = '+')) coxmf1 f1 <- cph(formula(coxmf1), data=df1, x=T, y=T, surv = T) surv1 <- Survival(f1) dd=datadist(df1) options(datadist="dd") nom1 <- nomogram(f1, fun=list(function(x) {surv1(1*12, x)}, function(x) {surv1(3*12, x)}, function(x) {surv1(5*12, x)}), funlabel=c("1-year Disease-free Probability", "3-year Disease-free Probability", "5-year Disease-free Probability")) options(repr.plot.width=12, repr.plot.height=8) plot(nom1, xfrac=.2) results <- formula_rd(nomogram = nom1) df$f1_points <- points_cal(formula = results$formula,rd=df) df years1 <- timeROC(T=df$time,delta=df$status, marker=df$f1_points,cause=1, weighting="marginal", times=12*c(1,3,5), ROC=T, iid=T) years1 auc1.ci <- confint(years1, parm=NULL, level = 0.95,n.sim=2000) auc1.ci <- auc1.ci$CI_AUC auc1.ci years1.auc1 <- paste0(round(years1$AUC[1],4)*100,'(',auc1.ci[1,1],'~',auc1.ci[1,2],')%') years1.auc2 <- paste0(round(years1$AUC[2],4)*100,'(',auc1.ci[2,1],'~',auc1.ci[2,2],')%') years1.auc3 <- paste0(round(years1$AUC[3],4)*100,'(',auc1.ci[3,1],'~',auc1.ci[3,2],')%') options(repr.plot.width=8, repr.plot.height=8) plot(years1,time=12*1,title="Time dependent ROC",col="#BC3C29FF") plot(years1,time=12*3,add=TRUE,col="#0072B5FF") plot(years1,time=12*5,add=TRUE,col="#E18727FF") legend("bottomright",c(paste("AUC of 1-year =",years1.auc1), paste("AUC of 3-year =",years1.auc2), paste("AUC of 5-year =",years1.auc3)), col=c("#BC3C29FF","#0072B5FF","#E18727FF"),lty=1,lwd=2)
|