[R] Function for AUC?
agoralczyk at gmail.com
Mon Dec 17 11:07:25 CET 2007
On Dec 17, 2007 9:57 AM, N. Lapidus <n.lapidus at gmail.com> wrote:
> Hi Armin,
> Do you know the rocr package ? This is very easy to draw ROC curves and to
> calculate AUC with it.
> Hope this will help.
I know ROCR although I am not familiar with ROC. I have seen the AUC
function of ROCR, but are you sure that this is applicable to the
stated problem, i.e. calculate AUC of serum levels of a drug over
time?! ROC seems to handle completely different problems.
I have been reading the following post (thanks for the hint Stephen):
> On Dec 17, 2007 2:58 AM, Stephen Weigand <weigand.stephen at gmail.com> wrote:
> > RSiteSearch("AUC")
> > would lead you to
> > http://finzi.psych.upenn.edu/R/Rhelp02a/archive/46416.html
I tried it:
> trap.rule <- function(x,y) sum(diff(x)*(y[-1]+y[-length(y)]))/2
It is not the correct value, but the formula seems applicable and I
changed it to
> auc <- function(x,y) sum((x[-length(x)] + x[-1]) * (y[-1]-y[-length(y)]))/2
which seems to be correct. I hope everyone agees.
I didn't know it's that simple. I guess I don't need another function.
Thank's for all the help and all the suggestions.
Armin Goralczyk, M.D.
Abteilung Allgemein- und Viszeralchirurgie
Dept. of General Surgery
University of Göttingen
More information about the R-help