Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing scale of the ROC chart

I am using the following code to plot the ROC curve after having run the logistic regression.

fit1 <- glm(formula=GB160M3~Behvscore, data=eflscr,family="binomial", na.action = na.exclude)
prob1=predict(fit1, type=c("response"))
eflscr$prob1 = prob1

library(pROC)
g1 <- roc(GB160M3~prob1, data=eflscr, plot=TRUE,  grid=TRUE, print.auc=TRUE)

The ROC curves plotted look like this (see link below)

enter image description here

  1. The x-axis scale does not fill the who chart.
  2. How can I change the x axis to report 1 - specifically?
like image 420
Manfred Avatar asked Dec 09 '16 09:12

Manfred


People also ask

Why do we vary threshold in plotting the ROC curve?

The ROC curve shows a trade-off between TPR and FPR (or false negatives and false positives). It plots TPR vs FPR at different thresholds. If we lower the classification threshold, we will classify more observations as positive, increasing True Positives. But this will cause even the false positives to increase.

How can I improve my ROC AUC score?

In order to improve AUC, it is overall to improve the performance of the classifier. Several measures could be taken for experimentation. However, it will depend on the problem and the data to decide which measure will work. (1) Feature normalization and scaling.

How do I choose a good ROC curve?

COMPARING ROC CURVESThe closer an ROC curve is to the upper left corner, the more efficient is the test. In FIG. XIII test A is superior to test B because at all cut-offs the true positive rate is higher and the false positive rate is lower than for test B.

Why does the ROC curve have 3 points?

If the output was only {0,1} the ROC would have three points (there are three possible thresholds with only two output values), so that point is invalid.


1 Answers

  1. By default pROC sets asp = 1 to ensure the plot is square and both sensitivity and specificity are on the same scale. You can set it to NA or NULL to free the axis and fill the chart, but your ROC curve will be misshaped.

    plot(g1, asp = NA)
    

    Using par(pty="s") as suggested by Joe is probably a better approach

  2. This is purely a labeling problem: note that the x axis goes decreasing from 1 to 0, which is exactly the same as plotting 1-specificity on an increasing axis. You can set the legacy.axes argument to TRUE to change the behavior if the default one bothers you.

    plot(g1, legacy.axes = TRUE)
    
like image 156
Calimo Avatar answered Sep 22 '22 13:09

Calimo