[R] Calculate the area under a curve

William Dunlap wdunlap at tibco.com
Mon Aug 24 19:32:38 CEST 2015


This is partly a bug in the AUC package and partly a problem
with you not reading or understanding the the help file for the
auc function in that package.  help(auc) says

         auc(x, min = 0, max = 1)

  Arguments:

         x: an object produced by one of the functions ‘sensitivity’,
            ‘specificity’, ‘accuracy’, or ‘roc’

and you give the output of lm(), not the output of one of the
functions listed there.

The auc() function should give a clear error message when
class(x) is not one of the expected classes.

When you encounter a problem in a user-contributed package
you should report it to the 'maintainer' of the package so the package
may be improved
   > maintainer("AUC")
   [1] "Michel Ballings <Michel.Ballings at UGent.be>"



Bill Dunlap
TIBCO Software
wdunlap tibco.com

On Mon, Aug 24, 2015 at 7:38 AM, CarstenH <cahoff at gmx.de> wrote:

> Hi Charles
>
> I am new in R and would like to learn/use it in the beginning for easy
> operations. I already used google for houres and did not find a solution
> for
> this in my eyes easy calculation process. I spent long time with reading
> forums, package handbooks, and tried and error but always failed. But I
> still believe that somebody could tell me something like: Load package XY
> and than use that command Z...
>
> Sorry if I am naive or half-baked but I guess there shout be a very easy
> command to calculate the area under a function.
>
>
> E.g. If I use the package AUC:
>
> auc(fitP, min=20, max=100)
> there is an error report which I do not understand:
> /Error in auc(fitP1, min = 20, max = 100) : object 'ans' not found.
> /
>
> My task in short:
>
> I have 20 x and associated 20 y values and created a function by
>
> fitP <- lm( y~poly(x,3,raw=TRUE) )
>
> the function looks like this:
>
> fitP
>
> /Call:
> lm(formula = y2 ~ poly(x2, 3, raw = TRUE))
>
>
> Coefficients:
>              (Intercept)  poly(x2, 3, raw = TRUE)1
>                1.125e+01                -5.262e-01
> poly(x2, 3, raw = TRUE)2  poly(x2, 3, raw = TRUE)3
>                9.156e-03                -4.771e-05
>
> /
>
> The last step now is to integrate the function. If I put this data by hand
> in any of many AUC-calculators in the web it works. But I still not find
> the
> "easy" way within R.
>
>
>
>
>
>
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Calculate-the-area-under-a-curve-tp4711418p4711434.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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]]



More information about the R-help mailing list