9

I would like to get the optimal cut off point of the ROC in logistic regression as a number and not as two crossing curves. Using the code below I can get the plot that will show the optimal point but in some cases I just need the point as a number that I can use for other calculations. Here are the code lines:

library(Epi)
ROC( form = IsVIP ~ var1+var2+var3+var4+var5, plot="sp", data=vip_data ) 

Thanks

horseoftheyear
  • 917
  • 11
  • 23
mql4beginner
  • 2,193
  • 5
  • 34
  • 73
  • I think you'll have to play with the returned values from `ROC` to create an equation/formula representing `curve1 - curve2` . Then use `uniroot` to find the zero point. I'm not familiar with this package, so there may be easier ways within the `Epi` package. – Carl Witthoft Apr 17 '14 at 11:43

1 Answers1

14

As per documentation the optimal cut-off point is defined as the point where Sensitivity + Specificity is maximal (see MX argument in ?ROC). You can get the according values as follows (see example in ?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]

This is the point that will be shown when you run

ROC(form = y ~ x + z, plot = "ROC", MX = TRUE)
adibender
  • 7,288
  • 3
  • 37
  • 41