在 ROC 函数中设置一个级别

setting a level in the ROC function

我正在尝试获取两个患者评分系统的能力及其预测入院的能力的 sens、spec、npv 和 ppv。数据说明:

'Etriage'是电子分诊系统(1-5分), AETriage 是一个面对面的分诊系统 (socres 1-5)。 录取有 2 个水平作为因素 0 - 未录取,1 - 录取。

例如:

df <- data.frame(
    Etriage=c(2,3,3,5,2,5,3,3,4,3),
    AETriage=c(3,4,4,3,2,4,4,3,4,1), 
    Admitted=c(1,0,0,0,0,0,0,0,0,1))

我想比较这两个分数预测录取的能力,一直在尝试使用 pROC 来做这个(取自整体数据集):

library(pROC)
auc(df$Admitted, df$AETriage)

ci.auc(df$Admitted, df$AETriage)
ROC_AETriage_Admitted<-roc(df$Admitted,df$AETriage)
print(ROC_AETriage_Admitted)

OperatingValuesAETriage <- coords(ROC_AETriage_Admitted, "all", 
    ret=c("sensitivity","specificity","npv","ppv","threshold"), transpose = FALSE)

print(OperatingValuesAETriage)

我将如何编码 2 个操作级别(低敏锐度 = 3-5 分和高敏锐度 = 1-2 分)并评估他们预测入院的能力?

谢谢!

您不能使用文本分数(或因素),因为为了构建 ROC 曲线,我们需要对数据进行 排名,这无法在简单文本上自动完成( “高”比“低”高吗?计算机不会知道的。

但是,R 有一个文本数据类型:ordered factors,pROC(在某种程度上)支持它:

df$Etriage_binary <- ordered(
    ifelse(df$Etriage <= 2, "High", "Low"),
    levels = c("Low", "High"))

pROC::auc(df$Admitted, df$Etriage_binary)

虽然没有准确报告阈值,但它有效,但是 this dichotomization is lossy and there are many reasons why you don't actually want to do it