calculating optimal threshold
library(pROC) my_roc <- roc(my_response, my_predictor) coords(my_roc, "best", ret = "threshold")