How can I get The optimal cutoff point of the ROC in logistic regression as a number

前端 未结 1 1212
悲&欢浪女
悲&欢浪女 2020-12-29 12:51

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

相关标签:
1条回答
  • 2020-12-29 13:35

    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)
    
    0 讨论(0)
提交回复
热议问题