I have 8 different diagnostic metric cut offs that I have calculated the True Positive Rate and False Positive Rate for. I have then plotted the different diagnostic metric points on a manually constructed ROC curve (just using ggplot and TPR vs FP). Data is:
Metric<-c("zero", "CORNER", "DOL", "GE", "K", "M", "F", "H", "L", "G")
FPR<-c(0, 0.11, 0.26, 0.07, 0.5, 0.07, 0.26, 0.05, 0.29, 0.03)
TPR<-c(0, 0.5, 0.9, 0.6, 0.9, 0.5, 0.9, 0.8, 0.9, 0.8)
#let us put these all into one table
FinalTable<-data.frame(Metric, FPR, TPR)
The code for the graph is below:
ggplot(FinalTable, aes(FPR, TPR))
geom_point()
I am trying to find the optimal point on this manually constructed ROC curve but I cannot seem to find the way to do it.
Anybody know how to do this (I do not want to construct multiple ROC curves as that would only tell me the youden index or AUC of 1 specific diagnostic cut off)?
CodePudding user response:
You could weigh the FPR and TPR equally and abstract them like TPR-FPR and find the maximum score, like this:
Metric<-c("zero", "CORNER", "DOL", "GE", "K", "M", "F", "H", "L", "G")
FPR<-c(0, 0.11, 0.26, 0.07, 0.5, 0.07, 0.26, 0.05, 0.29, 0.03)
TPR<-c(0, 0.5, 0.9, 0.6, 0.9, 0.5, 0.9, 0.8, 0.9, 0.8)
#let us put these all into one table
FinalTable<-data.frame(Metric, FPR, TPR)
# Determine score
FinalTable$score = FinalTable$TPR - FinalTable$FPR
# find max score
FinalTable[which.max(FinalTable$score),]
#> Metric FPR TPR score
#> 10 G 0.03 0.8 0.77