[R] How to calculate the AUC in R

Frank E Harrell Jr f.harrell at vanderbilt.edu
Mon Apr 11 19:34:38 CEST 2005


Dubas, João Paulo wrote:
> Hello R-listers,
> 
> I'm working in an experiment that try to determine the degree of 
> infection of different clones of a fungus and, one of the measures we 
> use to determine these degree is the counting of antibodies in the 
> plasma at different dilutions, in this experiment the maximum number of 
> dilutions was eleven. I already checked for differences on the maximum 
> concentration of the antibodies in function of each clone of the fungus. 
> However one measure of interest is the area under the curve (AUC) for 
> the counting of antibodies in function of dilution. Unfortunately I 
> don't know how to calculate the AUC. Someone can point me an example of 
> this procedure or a package that implements this calculation?
> 
> Thanks for the help,
> João Paulo Dubas.
> 

One of many ways:

trap.rule <- function(x,y) sum(diff(x)*(y[-1]+y[-length(y)]))/2


-- 
Frank E Harrell Jr   Professor and Chair           School of Medicine
                      Department of Biostatistics   Vanderbilt University




More information about the R-help mailing list