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.
Re: [R] ROC Analysis
Hi everybody, Pascal, your script works again but I want to calculate the LR otherwise. I know the likelihood ratio is linked at the roc curve and so there are different ways to calculate the LR. The slope of an ROC curve can be defined in three ways: (1) as the tangent at a particular point on the ROC curve corresponding to a test value x (2) as the slope between the origin 0 and the point on the ROC curve corresponding to a test value x (3) as the slope between two points on the ROC curve corresponding to the test values x and y http://r.789695.n4.nabble.com/file/n4478233/LR.png But in my case, I want calculated the LR with the third way. So, LR (x,y) =(sensitivity (x)-sensitivity (y))/(specificity (y)-specificity (x)) = (TPR(x)-TPR (y))/(FPR (x)-FPR (y)) It is possible ?! 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-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.
Re: [R] ROC Analysis
Hi, I made a mistake, effectively Pascal your method given to the first message is correct. I didn't use the good data, so it's sure that it could not work ! But, I have an another question : Can I obtain a same graph except that the y-axis represents the likelihood ratio ? 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-tp4469203p4475038.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.
Re: [R] ROC Analysis
Hi, Pascal, I tried to use your method which functions but the values of the abscissa are not good. When I talked about “value”, I wanted mean the values of my starting dataset that I have classified into two classes positive and negative classes, such as this : Value Status TPF TNF 10001 487 0 852 1 927 1 799 1 369 0 … … And for each value of my dataset, I want the tpf and tnf. With your method, I have an abscissa which has values between 0 and 1. 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-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.
Re: [R] ROC analysis
Eleni Christodoulou wrote: > Richard, thanks, I think it will work. I will calculate the cutoff value > and then, from the prediction object, find the fpr that is related to it and > put it as argument to performance. I will keep you informed. > > Eleni You will probably need to bootstrap the entire process to get a decent estimate of fpr as your cutoff was not specified in advance. Also note that you are implicitly assuming a constant utility function across all subjects because you are not using probabilities but are ignoring information by creating only a binary prediction. Frank Harrell > > On Wed, Mar 19, 2008 at 11:51 AM, Richard Pearson < > [EMAIL PROTECTED]> wrote: > >> Eleni >> >> Does the fpr.stop argument do what you want? This is described in >> ?performance under the details of the "auc" measure. Try, e.g. >> >> perform=performance(pred,measure="auc",fpr.stop=0.5) >> >> >> Richard. >> >> >> Eleni Christodoulou wrote: >>> Hello list, >>> >>> I am trying to perform ROC analysis and count the AUC in order to >> validate >>> my results. I use package ROCR. I would like to count the AUC not under >> the >>> cutoff found by "performance" but to use another cutoff that I >> calculate. >>> How could I change the following command in order to get what I want? >>> perform=performance(pred,measure="auc",x.measure="cutoff"), where pred >> is a >>> prediction object. >>> >>> Thank you very much, >>> Eleni >>> >>> [[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. >>> >>> >> __ >> 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. >> > > [[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. > -- Frank E Harrell Jr Professor and Chair School of Medicine Department of Biostatistics Vanderbilt University __ 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.
Re: [R] ROC analysis
Richard, thanks, I think it will work. I will calculate the cutoff value and then, from the prediction object, find the fpr that is related to it and put it as argument to performance. I will keep you informed. Eleni On Wed, Mar 19, 2008 at 11:51 AM, Richard Pearson < [EMAIL PROTECTED]> wrote: > Eleni > > Does the fpr.stop argument do what you want? This is described in > ?performance under the details of the "auc" measure. Try, e.g. > > perform=performance(pred,measure="auc",fpr.stop=0.5) > > > Richard. > > > Eleni Christodoulou wrote: > > Hello list, > > > > I am trying to perform ROC analysis and count the AUC in order to > validate > > my results. I use package ROCR. I would like to count the AUC not under > the > > cutoff found by "performance" but to use another cutoff that I > calculate. > > How could I change the following command in order to get what I want? > > perform=performance(pred,measure="auc",x.measure="cutoff"), where pred > is a > > prediction object. > > > > Thank you very much, > > Eleni > > > > [[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. > > > > > > __ > 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. > [[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.
Re: [R] ROC analysis
Eleni Does the fpr.stop argument do what you want? This is described in ?performance under the details of the "auc" measure. Try, e.g. perform=performance(pred,measure="auc",fpr.stop=0.5) Richard. Eleni Christodoulou wrote: > Hello list, > > I am trying to perform ROC analysis and count the AUC in order to validate > my results. I use package ROCR. I would like to count the AUC not under the > cutoff found by "performance" but to use another cutoff that I calculate. > How could I change the following command in order to get what I want? > perform=performance(pred,measure="auc",x.measure="cutoff"), where pred is a > prediction object. > > Thank you very much, > Eleni > > [[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. > > __ 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.