rggplot2data-visualizationroc

How to relevel in ROC curve in R/plotROC?


I have just started learning curves. I am trying to produce a ROC plot but it seems that the curve is bending the wrong direction than usual - please see attached

Can you help reverse the curve so that it bends in the "usual" direction?

enter image description here

My data is

p <- structure(list(t = c(29354L, 7445L, 22309L, 29699L, 29711L, 14765L, 22257L, 
29715L, 29772L, 13320L, 20905L, 12950L, 3400L, 14800L,7400L, 21890L, 19400L, 14800L, 14700L, 22200L, 1688L, 4500L, 8438L, 13500L, 14800L, 
12580L, 12950L, 13320L, 11840L, 13320L, 14800L, 13690L, 11250L, 12210L, 13320L, 13320L, 14800L, 12580L,20720L, 11840L, 14800L, 7030L, 14800L, 
14800L, 8325L, 11100L,10730L, 13690L, 12210L, 14800L), a = c(0L, 1L, 1L, 0L, 0L, 
1L,0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 1L, 0L, 0L, 0L, 0L, 0L, 1L, 0L,1L, 0L, 0L, 0L, 
0L, 1L, 0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 0L, 0L,0L, 0L, 0L, 1L, 0L, 0L, 1L, 0L, 0L, 
0L, 0L, 0L)), .Names = c("t","a"), class = "data.frame", row.names = c(NA, 50L))

And I used the following

library(plotROC)
basicplot <- ggplot(p, aes(d = p$a, m = p$t)) + geom_roc() + theme_bw()
basicplot + style_roc() 

Bonus questions

I used Youden's to determine the best cut-off, which was 13410. Any ideas how to draw specific attention to this point - eg by highlighting a red dot?


Solution

  • You can do two things, swap your 1 and 0 designations, or use geom_roc(increasing = FALSE). See the PlotROC vignette. This is assuming your model is actually performing this way, and doesn't truly have low sensitivity and a high false positive rate and you're just inverting it.

    basicplot <- ggplot(p, aes(d = a, m = t)) + 
        geom_roc(increasing = FALSE) + 
        theme_bw()
    
    basicplot + style_roc()