我希望能够以数字形式获取逻辑回归中ROC的最佳截断点,而不是两条交叉曲线。 使用以下代码,可以得到显示最佳点的绘图,但在某些情况下,我只需要将该点作为数字用于其他计算。 以下是代码行:
library(Epi)
ROC( form = IsVIP ~ var1+var2+var3+var4+var5, plot="sp", data=vip_data )
谢谢
?ROC
中的MX
参数)。您可以按以下方式获取相应的值(参见?ROC
中的示例):x <- rnorm(100)
z <- rnorm(100)
w <- rnorm(100)
tigol <- function(x) 1 - (1 + exp(x))^(-1)
y <- rbinom(100, 1, tigol(0.3 + 3*x + 5*z + 7*w))
rc <- ROC(form = y ~ x + z, plot="sp")
## optimal combination
opt <- which.max(rowSums(rc$res[, c("sens", "spec")]))
## optimal cut-off point
rc$res$lr.eta[opt]
这是运行时显示的点
ROC(form = y ~ x + z, plot = "ROC", MX = TRUE)
ROC
返回的值进行操作,以创建一个代表curve1 - curve2
的方程/公式。然后使用uniroot
来找到零点。我不熟悉这个包,所以在Epi
包内可能有更简单的方法。 - Carl Witthoft