Search code examples
rmachine-learningdata-sciencerocauc

R: AUC from pROC package


I recently came across pROC package to get AUC. In the help section, they give following example:

library("pROC")
data(aSAH)
auc(aSAH$outcome, aSAH$s100b)

In above, outcome is a factor whereas s100b is numerical.

My question is how does AUC work in this case? What threshold does it apply for s100b? Or it does not matter?

Edit 1 The above code results in AUC = 0.73. How do I know which threshold value was chosen to get this value?


Solution

  • The AUC in the auc function of pROC is the Area Under the ROC curve. Behind the scenes the function calls the roc function first, and so what you did is equivalent to:

    myroc <- roc(aSAH$outcome, aSAH$s100b)
    auc(myroc)
    

    The ROC curve is obtained by calculating sensitivity and specificity for all possible thresholds. You can visualize the curve with the plot function, and the AUC is shown in grey:

    plot(myroc, auc.polygon=TRUE)
    

    A ROC curve with the AUC displayed in grey