'Why is the roc function not determining cases and controls properly?

Under the default direction = "auto" setting of the roc function, it appears that cases and controls should be automatically configured such that the ROC curve for a predictor is above the diagonal of the plot and has an AUC >= 0.5.

However, the code shown below incorrectly assigns case and control values, creating an ROC curve whose AUC is < 0.5.

#Creation of data
data <- data.frame("Predictor" = c(rep(0, 59), rep(1, 29)), 
                   "Outcome" = c(rep(0, 40), rep(1, 19), rep(0, 22), rep(1, 7)))

#Fitting ROC
roc_obj <- pROC::roc(Outcome ~ Predictor, data = data)

#Plotting ROC to show that it is below the diagonal
pROC::ggroc(roc_obj) + 
  ggplot2::geom_abline(intercept = 1)

I am aware that I can fix this by manually setting the direction argument in a univariate setting, but I am ultimately attempting to create a multivariable ROC plot, for which I cannot manually provide the direction for each argument.

Is there something I can do to make the default direction = "auto" setting determine my cases and controls properly?

Thanks so much!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source