# [R] Fast AUC computation

Tuszynski, Jaroslaw W. JAROSLAW.W.TUSZYNSKI at saic.com
Thu Sep 29 17:03:24 CEST 2005

```See colAUC in caTools (there is a problem with 1.3 version, 1.4 is on the
way). See "examples" for other functions calculating AUC. An alternative
approach is:

x1 = x[y==1]; n1 = length(x1);
x2 = x[y==0]; n2 = length(x2);
r = rank(c(x1,x2))
auc = (sum(r[1:n1]) - n1*(n1+1)/2) / (n1*n2)

Which is very fast.

Jarek
====================================================\====
Jarek Tuszynski, PhD.                           o / \
Science Applications International Corporation  <\__,|
(703) 676-4192                                   ">  \
Jaroslaw.W.Tuszynski at saic.com                     `   \

-----Original Message-----
From: r-help-bounces at stat.math.ethz.ch
[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Nina Paynter
Sent: Wednesday, September 28, 2005 4:43 PM
To: r-help at stat.math.ethz.ch
Subject: [R] Fast AUC computation

I am doing a simulation with a relatively large data set (20,000
observations) for which I want to calculate the area under the Receiver
Operator Curve (AUC) for many parameter combinations.  I am using the ROC
library and the following commands to generate each AUC:

rocobj=rocdemo.sca(truth = ymis, data = model\$fitted.values, rule =
dxrule.sca) #generation of observed ROC object

aucobj=AUC(rocobj) #pulling out just the observed AUC - trapezoidal not
integrated

but they are pretty slow.

Does anyone know of a faster way to get the AUC?

Thanks,

Nina

[[alternative HTML version deleted]]

______________________________________________
R-help at stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help