Method 1: Using the plot() function So, let us try applying the ROC curve concept to the Logistic Regression model. In this example, we would model the Bank Loan Defaulter dataset using Logistic Regression. The ROC curve would be plotted using the plot() function from the 'pROC' library. The dataset can be found here!
pROC is a package for R and S+ specifically dedicated to ROC analysis. It proposes multiple statistical tests to compare ROC curves, and in particular partial areas under the curve, allowing proper ROC interpretation.
I am plotting ROCs and measuring partial AUC as a metric of ecological niche model quality. As I am working in R, I am using the ROCR and the pROC packages. I'll settle on one to use, but for now, I just wanted to see how they performed, and if one met my needs better.
One thing that confuses me is that, when plotting a ROC, the axes are as follows:
ROCR
x axis: 'true positive rate' 0 -> 1
y axis: 'false positive rate', 0 -> 1
pROC
x axis: 'sensitivity' 0 -> 1
y axis: 'specificity' 1 -> 0.
But if I plot the ROC using both methods, they look identical. So I just want to confirm that:
true positive rate = sensitivity
false positive rate = 1 - specificity.
Here is a reproducible example:
obs<-rep(0:1, each=50)
pred<-c(runif(50,min=0,max=0.8),runif(50,min=0.3,max=0.6))
plot(roc(obs,pred))
ROCRpred<-prediction(pred,obs)
plot(performance(ROCRpred,'tpr','fpr'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With