There are various packages that do ROC curves (others have mentioned some, you can search for the others), but ROC curves are not that hard to do by hand in R. Using the classic iris dataset, we can use Sepal.Length as the test/score and species=='virginica' as the true pos/neg that we are trying to predict. One way to compute the ROC curve, auc and values is:
> xx <- c( -Inf, sort(unique(iris$Sepal.Length)), Inf ) > sens <- sapply(xx, function(x) with(iris, + mean( Sepal.Length[Species=='virginica'] >= x ) ) ) > spec <- sapply(xx, function(x) with(iris, + mean( Sepal.Length[Species!='virginica'] < x ) ) ) > plot( 1-spec, sens, type='l' ) > > ch <- chull(1-spec,sens) > lines(1-spec[ch], sens[ch], col='green') > > integrate( approxfun(spec, sens), 0, 1) # Area under curve Hope this helps, -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare [EMAIL PROTECTED] 801.408.8111 > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > project.org] On Behalf Of Pau Marc Munoz Torres > Sent: Friday, October 31, 2008 8:25 AM > To: r-help@r-project.org > Subject: [R] how to compute a roc curve > > Hi, > > I'm trying to set up a prediction software, now i testing the > performance of my method, so i need to calculate a ROC curve, specially > auc, cut-off, sens and spec, i just looking at ROCH package, but it's a > mass for me, i'm not a math guy and I'm getting lost > > Could any of you recommend me an easy-to-use package to do this task? i > just have a list of positive/negative samples and his score on my > program. can I compute a roc curve with this? > > thanks > > pau > -- > Pau Marc Muñoz Torres > > Laboratori de Biologia Computacional > Institut de Biotecnologia i Biomedicina Vicent Villar > > Universitat Autonoma de Barcelona > E-08193 Bellaterra (Barcelona) > > telèfon: 93 5812807 > Email : [EMAIL PROTECTED] > > [[alternative HTML version deleted]] ______________________________________________ R-help@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.