R软件:如何画ROC曲线
> install.packages("pROC") 安装pROC包
> install.packages("ggplot2")安装ggplot2包
library(pROC) #调用pROC包
library(ggplot2) #安装ggplot包
data(aSAH)# 引入案例数据
View(aSAH) #展示案例数据

roca<-roc(aSAH$outcome,aSAH$s100b)
rocb<-roc(aSAH$outcome,aSAH$wfns)
rocc<-roc(aSAH$outcome,aSAH$ndka)
auc(roca)
auc(rocb)
auc(rocc)
> auc(roca)
Area under the curve: 0.7314
> auc(rocb)
Area under the curve: 0.8237
> auc(rocc)
Area under the curve: 0.612
>
plot(roca)

plot(rocb)

#ROC曲线下面积的比较
roc.test(roca,rocb,method = "delong")
DeLong's test for two correlated ROC curves
data: roca and rocb
Z = -2.209, p-value = 0.02718
alternative hypothesis: true difference in AUC is not equal to 0
sample estimates:
AUC of roc1 AUC of roc2
0.7313686 0.8236789
g3<-ggroc(list(s100b=roca,wfns=rocb,ndka=rocc))
g3


4579

被折叠的 条评论
为什么被折叠?



