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)
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
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)