R语言两个ROC的比较

一、概述

ROC是以真阳性率(灵敏度)为纵坐标,以假阳性率(特异度)为纵坐标所绘制的曲线,可以通过不同截断点下的ROC曲线下的面积(AUC),可用于判断该检验方法的诊断价值,正好解决了敏感度和特异度的选择问题。如果AUC小于0.5则表示试验无诊断价值,另外AUC面积越大,表明实验的准确性越高。但是如果两个试验参数的AUC面积都大于0.5,那我们该如何比较这两个ROC指标的诊断能力是否有差别呢?

二、数据集展示

这里就不以科研数据来做展示了,防止泄露个人研究信息,统一采用R语言自带的数据集,接下来就使用pROC自带的数据集aSAH进行演示:

> library(pROC)
Type 'citation("pROC")' for a citation.

载入程辑包:‘pROC’

The following object is masked _by_ ‘.GlobalEnv’:

    aSAH

The following objects are masked from ‘package:stats’:

    cov, smooth, var

Warning message:
程辑包‘pROC’是用R版本4.0.5 来建造的 
> data(aSAH)
> head(aSAH)
   gos6 outcome gender age wfns s100b  ndka
29    5    Good Female  42    1  0.13  3.01
30    5    Good Female  37    1  0.14  8.54
31    5    Good Female  42    1  0.10  8.09
32    5    Good Female  27    1  0.04 10.42
33    1    Poor Female  42    3  0.13 17.40
34    1    Poor   Male  48    2  0.10 12.75

三、两个ROC的比较

1. 比较

> roc_model1 <- roc(outcome~age,data=aSAH) #roc曲线模型1
Setting levels: control = 0, case = 1
Setting direction: controls < cases
> roc_model2 <- roc(outcome~s100b,data=aSAH) #roc曲线模型2
Setting levels: control = 0, case = 1
Setting levels: control = 0, case = 1
Setting direction: controls < cases
> roc.test(roc_model1,roc_model2)

        DeLong's test for two correlated ROC curves

data:  roc_model1 and roc_model2
Z = -1.7604, p-value = 0.07835
alternative hypothesis: true difference in AUC is not equal to 0
sample estimates:
AUC of roc1 AUC of roc2 
  0.6150068   0.7313686 

2. 画图

> plot(roc_model1) # 画出roc_model1的roc曲线
> lines(roc_model2,col="red") # 将roc_model2的roc曲线追加到model1的图中
> test <- roc.test(roc_model1,roc_model2) # 获取比较结果并赋值给test
> text(0.5,0.5,labels = paste("P-value =",round(test$p.value,3))) # 将比较结果p值展示在图中
> legend("bottomright",legend=c("age","s100b"),col=c(1,2),lwd = 2) # 画出legend框
> 

四、结果分析

在进行结果分析之前,先容我科普一下P值。

1. p值是否显著

统计学根据显著性检验方法所得到的P 值,其含义是样本间的差异由抽样误差所致的概率小于0.05 、0.01、0.001。

  1. 一般以P < 0.05 为有统计学差异
  2. P<0.01 为有显著统计学差异
  3. P<0.001为有极其显著的统计学差异。

2. 结果分析

从比较结果来看,虽然s100b的AUC为0.7313686大于年龄对应的AUC(0.6150068),但是其没有统计学差异(p = 0.078),因此不能认为这两个指标的诊断能力有差别。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

笑不语

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值