我想使用ROCit创建ROC曲线。我可以改变方向来计算ROC曲线吗(高值与健康有关)?
install.packages("ROCit")
require(ROCit)
由于问题中没有示例,所以我将从?rocit
文档中的示例开始,如果我对您的问题有误解,请告诉我。
# Load some example data
data("Diabetes")
# Calculate some ROC/validation data
roc_empirical <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "-") # default method empirical
roc_binormal <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "-", method = "bin")
# Summarize and plot the results
summary(roc_empirical) #60/329
summary(roc_binormal)
plot(roc_empirical)
plot(roc_binormal, col = c("#00BA37", "#F8766D"),
legend = FALSE, YIndex = FALSE)
我们可以查看summary(roc_empirical)
的输出作为基准:
Empirical ROC curve Number of postive responses : 60 Number of negative responses : 329 Area under curve : 0.652684903748734
现在,如果我理解(?),您只是想翻转参考值的含义/方向,在这种情况下为Diabetes$dtest
?
我们可以使用negref
参数完成此操作:
roc_empirical <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "+") # default method empirical
roc_binormal <- rocit(score = Diabetes$chol, class = Diabetes$dtest,
negref = "+", method = "bin")
summary(roc_empirical)
summary(roc_binormal)
plot(roc_empirical)
plot(roc_binormal, col = c("#00BA37", "#F8766D"),
legend = FALSE, YIndex = FALSE)
并且我们可以将summary(roc_empirical)
的结果与之前看到的“翻转”进行比较:
Empirical ROC curve Number of postive responses : 329 Number of negative responses : 60 Area under curve : 0.353850050658561
当然,您也可以重新编码所讨论的列。
这就是您所需要的吗?