对一组数据进行ROC分析后,如何计算p值?使用相同的统计数据,我看到 p 值可以在 SPSS 中输出。示例代码如下:
library(pROC)
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
(rr <- roc(aSAH$outcome, aSAH$s100b, plot=T))
# Setting levels: control = Good, case = Poor
# Setting direction: controls < cases
#
# Call:
# roc.default(response = aSAH$outcome, predictor = aSAH$s100b, plot = F)
#
# Data: aSAH$s100b in 72 controls (aSAH$outcome Good) < 41 cases (aSAH$outcome Poor).
# Area under the curve: 0.7314
编辑:
SPSS计算出来的p值是0.000007,但是计算出来的p值verification::roc.area()
是0.000022546,是不是和SPSS的计算方法roc.area()
不一致?
levels(aSAH$outcome) <- c(0, 1)
library(verification)
ra <- roc.area(as.numeric(as.vector(aSAH$outcome)), rr$predictor)
ra$p.value
# [1] 0.00002254601