You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何计算两条ROC曲线AUC差值的95%CI?pROC的roc.test不输出CI怎么办

问题解决方法

原因说明

pROC 1.17.0.1版本的roc.test函数中,DeLong检验默认不输出AUC差值的置信区间,仅指定conf.level参数不会触发置信区间计算,需要额外显式添加conf.int = TRUE参数开启置信区间输出功能。

修正后代码

library(pROC)
data(aSAH)

roc1 <- roc(aSAH$outcome, aSAH$s100b)
roc2 <- roc(aSAH$outcome, aSAH$wfns)
# 新增conf.int = TRUE参数
test_res <- roc.test(roc1, roc2, method="delong", paired=TRUE,
        alternative="two.sided", conf.level=0.95, reuse.auc=TRUE, conf.int = TRUE)
# 打印结果即可看到置信区间
print(test_res)

输出效果参考

修正后运行结果会多出置信区间相关行,示例如下:

DeLong's test for two correlated ROC curves
data: roc1 and roc2
Z = -2.209, p-value = 0.02718
alternative hypothesis: true difference in AUC is not equal to 0
95 percent confidence interval:
-0.17162278 -0.01299771
sample estimates:
AUC of roc1 AUC of roc2
0.7313686 0.8236789

如果需要单独提取AUC差值的置信区间,可直接访问结果对象的对应属性:
test_res$conf.int

内容的提问来源于stack exchange,提问作者gradstudent4life

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 07:27:05