【发布时间】:2014-01-13 21:05:08
【问题描述】:
我在使用 pROC 包绘制 ROC 曲线时遇到了两个问题。
A. 显着性水平或 P 值是当 ROC 曲线下的真实(总体)面积实际上为 0.5(零假设:面积 = 0.5)。如果 P 较小(P
因此,我想计算ROC曲线下的某个面积是否与0.50有显着差异。我找到了使用 pROC 包比较两条 ROC 曲线的代码,如下所示,但不确定如何测试它是否为 0.5 显着。
library(pROC)
data(aSAH)
rocobj1 <- plot.roc(aSAH$outcome, aSAH$s100,
main="Statistical comparison",
percent=TRUE, col="#1c61b6")
rocobj2 <- lines.roc(aSAH$outcome, aSAH$ndka,
percent=TRUE, col="#008600")
testobj <- roc.test(rocobj1, rocobj2)
text(50, 50,
labels=paste("p-value =", format.pval(testobj$p.value)),
adj=c(0, .5))
legend("bottomright", legend=c("S100B", "NDKA"),
col=c("#1c61b6", "#008600"), lwd=2)
B. 我已经对我的分类问题进行了 k 折交叉验证。例如,5 折交叉验证将产生 5 条 ROC 曲线。那么如何使用 pROC 包绘制这 5 条 ROC 曲线的平均值(我想要做的是在这个网页上解释,但在 Python 中完成:enter link description here)?另一件事是我们能否得到这条平均 ROC 曲线的置信区间和最佳阈值(类似于下面实现的代码)?
rocobj <- plot.roc(aSAH$outcome, aSAH$s100b,
main="Confidence intervals",
percent=TRUE, ci=TRUE, # compute AUC (of AUC by default)
print.auc=TRUE) # print the AUC (will contain the CI)
ciobj <- ci.se(rocobj, # CI of sensitivity
specificities=seq(0, 100, 5)) # over a select set of specificities
plot(ciobj, type="shape", col="#1c61b6AA") # plot as a blue shape
plot(ci(rocobj, of="thresholds", thresholds="best")) # add one threshold
参考:
http://web.expasy.org/pROC/screenshots.html
http://scikit-learn.org/0.13/auto_examples/plot_roc_crossval.html
http://www.talkstats.com/showthread.php/14487-ROC-significance
【问题讨论】:
-
这应该是两个不同的问题。
标签: r cross-validation roc