0

I want to cycle compare several logistic regression models. And print in one chart several ROC curves. How I can do this? For example, for one model it looks like

pred_fit4 <- prediction(workData$pred,workData3$value)
perf_fit4 <- performance(pred_fit4,"tpr","fpr")
roc <- plot(perf_fit4,colorize = T, print.cutoffs.at = seq(0,1),)

and its curve output as below:

enter image description here

And how can I add a new line? It looks like

for (...) {
.......
.......
    pred_fit4 <- prediction(workData$pred,workData3$value)
    perf_fit4 <- performance(pred_fit4,"tpr","fpr")
    #need add line on exist chart
    roc <- plot(perf_fit4,colorize = T , print.cutoffs.at = seq(0,1),)
}
5
  • 1
    have you looked at something like this : par(mfrow=c(nrow,ncol)) ? Where nrow and ncol define the grid of plots Commented Feb 7, 2016 at 12:03
  • Welcome to SO. You should be able to add lines to an existing base plot using lines() (help ?lines). There are numerous examples for that on SO. Please get in the habit of providing minimal reproducible (!) examples ready to copy & paste, so that others can play around with it, Commented Feb 7, 2016 at 12:55
  • Is this what you want to accomplish? statmethods.net/advgraphs/layout.html Commented Feb 7, 2016 at 13:28
  • When you say "add a new line", do you mean the "line of no-discrimination" from (0,0) to (1,1), or (0,0) to (0.32,1), or where? Commented Dec 3, 2016 at 19:08
  • Possible duplicate of plot multiple ROC curves for logistic regression model in R Commented Nov 9, 2017 at 22:27

1 Answer 1

1

This is using a package pROC. You can create a ROC object and then add to the same graph using lines and add as many ROC as you want.

obj.rpart1=roc(label1 ~ p1.rpart, smooth = T)
obj.rpart2=roc(label1 ~ p1.rpart, smooth = T)
plot(obj.rpart)
lines(obj.rpart2)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.