I'm trying to make overlaid ROC curves to represent successive improvements in model performance when particular predictors are added one at a time to the model. I want one ROC curve for each of about 5 nested models (which I will define manually), all overlaid in one plot. For example:
#outcome var
y = c(rep(0,50), rep(1, 50))
#predictors
x1 = y + rnorm(100, sd = 1)
x2 = y + rnorm(100, sd = 4)
#correlations of predictors with outcome
cor(x1, y)
cor(x2, y)
library(Epi)
ROC(form = y ~ x1, plot = "ROC)
ROC(form = y ~ x1 + x2, plot = "ROC")
I'd want the two ROC curves on the same plot (and ideally without the distracting model info in the background). Any ggplot/graphics gurus willing to lend a hand?
Best Answer
The
caTools
package provides thecolAUC
function. Use it and set theplotROC
argument to TRUE. I have been satisfied with the graphs it produces.