CVSummary1SAMP<-function(CVRes){ CVRes<-CVRes[with(CVRes,order(id)),] p<-seq(0,1,0.01) ##sets up a grid of different cutoff values. l_p<-length(p) AUC<-Sensitivity<-Specificity<-New_Sensitivity<-New_Specificity<-PCC<-New_PCC<-PPV<-NPV<-Unclass<-WidthCI<-Cutoff<-Mean_Lead_time<-Median_Lead_time<-ProbPredREF<-vector(length=6) Mean_Pred_time<-Median_Pred_time<-Mean_Obs<-Median_Obs<-Mean_TotalObs<-Median_TotalObs<-My_Specificity<-My_Sensitivity<-My_PCC<-My_PPV<-My_NPV<-vector(length=6) SensMtot<-SpecMtot<-SensCtot<-SpecCtot<-SensREtot<-SpecREtot<-SensMCItot<-SpecMCItot<-SensCCItot<-SpecCCItot<-SensRECItot<-SpecRECItot<-vector(length=6) PCCMtot<-PCCCtot<-PCCREtot<-PCCMCItot<-PCCCCItot<-PCCRECItot<-PPVMtot<-PPVCtot<-PPVREtot<-PPVMCItot<-PPVCCItot<-PPVRECItot<-NPVMtot<-NPVCtot<-NPVREtot<-NPVMCItot<-NPVCCItot<-NPVRECItot<-vector(length=6) SensMtotNew<-SpecMtotNew<-SensCtotNew<-SpecCtotNew<-SensREtotNew<-SpecREtotNew<-SensMCItotNew<-SpecMCItotNew<-SensCCItotNew<-SpecCCItotNew<-SensRECItotNew<-SpecRECItotNew<-vector(length=6) PCCMtotNew<-PCCCtotNew<-PCCREtotNew<-PCCMCItotNew<-PCCCCItotNew<-PCCRECItotNew<-vector(length=6) MyPCCMCItot<-MyPCCCCItot<-MyPCCRECItot<-MySpecMCItot<-MySpecCCItot<-MySpecRECItot<-MyNPVMCItot<-MyNPVCCItot<-MyNPVRECItot<-vector(length=6) Resul<-CVRes ##Label the number of the observation. for(i in unique(Resul$id)){Resul$Ob[Resul$id == i] <- 1:sum(Resul$id == i)} IndProf <- getProfiles(t="time", y=c("Marg2","Cond2","RanEf2","Marg2L","Marg2H","Cond2L","Cond2H","RanEf2L","RanEf2H","Status","Ob"),id="id", data=Resul) l<-length(unique(Resul$id)) SANAD_status<-1-aggregate(Status~id,max,data=Resul)$Status Allocation_Marg<-matrix(nrow=l,ncol=l_p) Allocation_Cond<-matrix(nrow=l,ncol=l_p) Allocation_RE<-matrix(nrow=l,ncol=l_p) Allocation_Marg_CI<-matrix(nrow=l,ncol=l_p) Allocation_Cond_CI<-matrix(nrow=l,ncol=l_p) Allocation_RE_CI<-matrix(nrow=l,ncol=l_p) Pred_timeM<-matrix(nrow=l,ncol=l_p) Pred_timeC<-matrix(nrow=l,ncol=l_p) Pred_timeRE<-matrix(nrow=l,ncol=l_p) Pred_timeMCI<-matrix(nrow=l,ncol=l_p) Pred_timeCCI<-matrix(nrow=l,ncol=l_p) Pred_timeRECI<-matrix(nrow=l,ncol=l_p) Ob_timeM<-matrix(nrow=l,ncol=l_p) Ob_timeC<-matrix(nrow=l,ncol=l_p) Ob_timeRE<-matrix(nrow=l,ncol=l_p) Ob_timeMCI<-matrix(nrow=l,ncol=l_p) Ob_timeCCI<-matrix(nrow=l,ncol=l_p) Ob_timeRECI<-matrix(nrow=l,ncol=l_p) Final_timeM<-vector(length=l) for(k in 1:l_p){ for(i in 1:l){ Prof<-IndProf[[i]] l_prof<-dim(Prof)[1] ##Number of visits for patient i Final_timeM[i]<-Prof[l_prof,"time"] for(j in 1:l_prof){ifelse(Prof[j,"Marg2"]>p[k],{Allocation_Marg[i,k]<-1;Pred_timeM[i,k]<-Prof[j,"time"];Ob_timeM[i,k]<-Prof[j,"Ob"];break},{Allocation_Marg[i,k]<-0;Pred_timeM[i,k]<-Prof[j,"time"];Ob_timeM[i,k]<-Prof[j,"Ob"]})} for(j in 1:l_prof){ifelse(Prof[j,"Cond2"]>p[k],{Allocation_Cond[i,k]<-1;Pred_timeC[i,k]<-Prof[j,"time"];Ob_timeC[i,k]<-Prof[j,"Ob"];break},{Allocation_Cond[i,k]<-0;Pred_timeC[i,k]<-Prof[j,"time"];Ob_timeC[i,k]<-Prof[j,"Ob"]})} for(j in 1:l_prof){ifelse(Prof[j,"RanEf2"]>p[k],{Allocation_RE[i,k]<-1;Pred_timeRE[i,k]<-Prof[j,"time"];Ob_timeRE[i,k]<-Prof[j,"Ob"];break},{Allocation_RE[i,k]<-0;Pred_timeRE[i,k]<-Prof[j,"time"];Ob_timeRE[i,k]<-Prof[j,"Ob"]})} for(j in 1:l_prof){ifelse(Prof[j,"Marg2L"]>p[k],{Allocation_Marg_CI[i,k]<-1;Pred_timeMCI[i,k]<-Prof[j,"time"];Ob_timeMCI[i,k]<-Prof[j,"Ob"];break},{ifelse(Prof[j,"Marg2H"]
p[k],{Allocation_Cond_CI[i,k]<-1;Pred_timeCCI[i,k]<-Prof[j,"time"];Ob_timeCCI[i,k]<-Prof[j,"Ob"];break},{ifelse(Prof[j,"Cond2H"]
p[k],{Allocation_RE_CI[i,k]<-1;Pred_timeRECI[i,k]<-Prof[j,"time"];Ob_timeRECI[i,k]<-Prof[j,"Ob"];break},{ifelse(Prof[j,"RanEf2H"]