I am trying to calculate the cut-off point that max sensitivity vs specifity. I am using the ROCR package and I have managed to plot the graph sensitivity vs specifity. However, I don't know how to calculate what is the cut off point that max sensitivity vs specifity. Ideal I would like to have a label in the graph that shows the cut off and the coordenates at the point. But, any suggestion to solve this question will be greatly appreciated.
pred <- prediction( ROCR.simple$hello, ROCR.simple$labels)
ss <- performance(pred, "sens", "spec")
plot(ss)
"Maximize sensitivity vs. specificity" isn't very precise, because you are trading these quantities off at each point along the ROC curve. To make it more precise, I'll assume you are trying to maximize the sum of these two values. Let's look at your example, which uses
ROCR.simple
:You can identify the cutoff that yields the highest sensitivity plus specificity with:
The highest sensitivity plus specificity is achieved in this case when you predict the positive outcome when the predicted probability exceeds 0.501 and predict the negative outcome when the predicted probability does not exceed 0.501. This yield a sensitivity plus specificity value of 1.7.
Naturally, this can be extended to other functions of the sensitivity and specificity by changing the expression inside the
which.max
call.