[R] How can I plot several ROC curves on the same graph?

From: <meytar_at_techunix.technion.ac.il>
Date: Mon, 28 Mar 2011 12:35:16 +0200


Hello
I am trying to make a graph of 10 different lines built each from 4 different segments and to add a darker line that will represent the average of all graphs - all in the same plot.Actually each line is a ROC plot The code I'm using for plotting one line is as follows:

logit.roc.plot <- function(r, title="ROC curve") { old.par <- par(no.readonly = TRUE); on.exit(par(old.par)) par(xaxs="i", yaxs="i")
plot(1 - r$spec, r$sens, xlim=c(0, 1), ylim=c(0,1), type="l", xlab="(1 - specificity): false positive rate", ylab="sensitivity: true positive rate",
col="grey82", lwd=2);
points(1 - r$spec, r$sens,pch=20, cex=1.5, col="grey82") abline(0, 1, lty=2);
segments(1-r$spec, 1-r$spec, 1-r$spec, r$sens, lty=3) #text(1 - max(r$spec,na.rm=T),
r$sens[which.max(r$spec)],r$pts[which.max(r$spec)],pos=2,cex=0.8) text(0, 0.9, paste("Area under ROC:",round(logit.roc.area(r),4)), pos=4) title(main = title)
}
r[5,]=c(0,0,1,10)
logit.roc.plot(r)
r=r[-5,]

text(1 - max(r$spec,na.rm=T),
r$sens[which.max(r$spec)],r$pts[which.max(r$spec)],pos=2,cex=0.8)

while r is a MATRIX (4x4) with
colnames=c("pts",sens","spec",iterationnumber.") and I have for each ROC curve a different matrix but all matrices have the same size. (They are organized as a list of 10 matrices by the size 4X4 each)

Would appreciate your help in putting all ROC curves on the same plot. Thank you

-- 
Meytar

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 28 Mar 2011 - 12:40:00 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 28 Mar 2011 - 12:40:24 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive