我想使用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
当然,您也可以对有问题的列进行重新编码。
这就是你所需要的吗?