ROC曲线和PR曲线也是一样的画,这里只演示下ROC: library(ROCR)pred <- prediction(pred_prob,train$Status) # 预测概率,真实类别perf <- performance(pred, "tpr","fpr")auc <- round(performance(pred, "auc")@y.values[[1]],digits = 4)#aucplot(perf,lwd=2,col="tomato")abline(0,1,lty=2)leg...
## cov, smooth, var #建立ROC对象 roc1 <- roc(df$MPE,lr_pred) ## Setting levels: control = No, case = Yes ## Setting direction: controls < cases #绘制ROC曲线 plot(roc1) #计算AUC auc(roc1) ## Area under the curve: 0.8174‘ #计算AUC的95%置信区间 ci(roc1) ## 95% CI: 0.76...
plot(roc3, add=TRUE, col="green") plot(roc4, add=TRUE, col="black") 1. 2. 3. 4. 添加图例 legend("bottomright", legend=c("roc1","roc2","roc3","roc4"),col=c("red","blue","green","black"),lty=1) 1. 我们先求出每个曲线的AUC round(auc(roc1),3)##AUC round(ci(roc...
2. 计算95%可信区间 > library(dplyr) 载入程辑包:‘dplyr’ The following objects are masked from ‘package:stats’: filter, lag The following objects are masked from ‘package:base’: intersect, setdiff, setequal, union > ci.auc(roc1) 95% CI: 0.5082-0.7219 (DeLong) 3. 计算p值 由于out...
plot(roc5, add=TRUE, col='orange') round(auc(roc1),3)##AUC round(ci(roc1),3)##95%CI round(auc(roc2),3)##AUC round(ci(roc2),3)##95%CI round(auc(roc3),3)##AUC round(ci(roc3),3)##95%CI round(auc(roc4),3)##AUC ...
pROC包可以计算AUC和95%置信区间,可以可视化、平滑和比较ROC曲线。 pROC包中的常用缩写: 下面来学习下怎么使用pROC包来可视化ROC曲线的置信区间。 目录 1. 安装和加载R包 2. 读取内置数据集 3. 建立拟合曲线 4. 可视化ROC曲线的CI 4.1 可视化阈值的CI ...
auc=round(roc.p$auc,3),cutoff=cutoff, sensitivity=sensitivity,specificity=specificity,ci_lower = ci[1],ci_upper=ci[3]) return(df) } else{ cutoff=roc.p$thresholds[which.min(roc.p$sensitivities+roc.p$specificities)] sensitivity=roc.p$sensitivities[which.min(roc.p$sensitivities+roc.p$specific...
(outcome~a+b+c,data=ROC,aur=TRUE,ci=TRUE,# 显示95%CI# percent=TRUE, ##是否需要以百分比显示levels=c('group1','group2'),direction=">"#设置分组方向)## 平滑曲线的ROC结果smooth<-roc(outcome~a+b+c,data=ROC,aur=TRUE,ci=TRUE,# 显示95%CI# percent=TRUE, ##是否需要以百分比显示smooth=...
接下来我们可以根据每一份的数据建立方程,并求出AUC,95%CI和截点,并且画出ROC曲线 我们先来做第一个数据的,要提取列表的数据,需要做成[[1]]这种形式, fold_test <- bc[folds[[1]],]#取fold 1数据,建立测试集和验证集 fold_train <- bc[-folds[[1]],]# ...
methods ="Youden", ci.fit =TRUE,data=zwang ) summary(optimal.cutpoint.Youden.p) √结果2: Call: optimal.cutpoints.default(X ="p",status="result", tag.healthy =0, methods ="Youden",data= zwang, ci.fit =TRUE) Areaunde...