[R] Re : ROC Analysis
Hi Camille, Probably you have to check wether there is any infinte value in x. Or calculate something like that for your x-axis: x[1:(ll-1)]+diff(x)/2 Regards, Pascal - Mail original - De : Camille Leclerc camille.lecl...@ymail.com À : r-help@r-project.org Cc : Envoyé le : Lundi 26 mars 2012 0h32 Objet : Re: [R] ROC Analysis Hi everybody, Pascal, your code works, but when I want to do the graph I have an error message. here is my code : x-rev(unlist(pred@cutoffs)) tpf-unlist(performance(pred, tpr)@y.values) fpf-unlist(performance(pred,fpr)@y.values) ll-length(x) p-(tpf[1:(ll-1)]-tpf[2:ll])/(fpf[1:(ll-1)]-fpf[2:ll]) plot(x,p) *Erreur dans xy.coords(x, y, xlabel, ylabel, log) : 'x' and 'y' lengths differ* So, when I look the lenghts of x and p, I have this : *x : numeric[1735] p : numeric[1734]* On the other hand, it's normal since I have the slope between two points on the ROC curve and so I have x points and x-1 slope values. How to get the graph?! All the best, Camille - -- Camille Leclerc, Master student Lab ESE, UMR CNRS 8079 Univ Paris-Sud Bat 362 F-91405 Orsay Cedex FRANCE -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4503354.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
[R] Re : ROC Analysis
Hi Camille, Does following work? ll - length(x) (TPR[1:(ll-1)]-TPR[2:ll])/(FPR[1:(ll-1)]-FPR[2:ll]) Regards, Pascal -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4478233.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
[R] Re : ROC Analysis
Hi Camille, Probably by adding these lines: fpf - unlist(performance(pred,fpr)@y.values) fnf - unlist(performance(pred,fnr)@y.values) pLhood - tpf/fpf # Positive Likelihood Ratio nLhood - fnf/tnf # Negative Likelihood Ratio par(mfrow=c(1,2)) plot(x, pLhood, t='l', xlab='Value', ylab='Positive Likelihood Ratio') plot(x, nLhood, t='l', xlab='Value', ylab='Negative Likelihood Ratio') Regards, Pascal __ 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. __ 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.
[R] Re : ROC Analysis
Hi Camille, Do you need something like that? ### library(ROCR) data(ROCR.simple) pred - prediction(ROCR.simple$predictions, ROCR.simple$labels) tpf - unlist(performance(pred,tpr)@y.values) tnf - unlist(performance(pred,tnr)@y.values) x - rev(unlist(pred@cutoffs)) plot(x, tpf+tnf, t='l', xlab='Value', ylab='TPF+TNF') ### Regards, Pascal - Mail original - De : Camille Leclerc camille.lecl...@ymail.com À : r-help@r-project.org Cc : Envoyé le : Mardi 13 mars 2012 23h30 Objet : [R] ROC Analysis Hi everybody, I have a data set with a value and a status (positive or negative case) and I want make a ROC Analysis. So, with ROCR Package, I have got the ROC curve (True Positive Fraction [tpf] according 1-True Negative Fraction [1-tnf]). http://r.789695.n4.nabble.com/file/n4469203/01.png But, now I want a new graphic which show the sum of true positive fraction and true negative fraction according each value on my data set (tpf + tnf according the values). http://r.789695.n4.nabble.com/file/n4469203/02.png If you have an idea ! Thank you very much for all help, Camille Leclerc -- Camille Leclerc, Master student Lab ESE, UMR CNRS 8079 Univ Paris-Sud Bat 362 F-91405 Orsay Cedex FRANCE -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4469203.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.
[R] Re : ROC Analysis
Hi Camille, I am surprised by your answer. If you do: pred - prediction(ROCR.simple$predictions*1000, ROCR.simple$labels) x - rev(unlist(pred@cutoffs)) You can see than x values are now between 0 and 1000. So, it should be probably the same for your data. Regards, Pascal -- View this message in context: http://r.789695.n4.nabble.com/ROC-Analysis-tp4469203p4471300.html Sent from the R help mailing list archive at Nabble.com. __ 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. __ 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.