[R] plotting several ROC curves on the same graph
meytar
meytar at techunix.technion.ac.il
Tue Mar 29 11:48:12 CEST 2011
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
--
View this message in context: http://r.789695.n4.nabble.com/plotting-several-ROC-curves-on-the-same-graph-tp3414263p3414263.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list