[R] How to calculate the area under the curve
William Dunlap
wdunlap at tibco.com
Thu Oct 22 16:59:47 CEST 2009
> -----Original Message-----
> From: r-help-bounces at r-project.org
> [mailto:r-help-bounces at r-project.org] On Behalf Of olivier.abz
> Sent: Thursday, October 22, 2009 7:23 AM
> To: r-help at r-project.org
> Subject: [R] How to calculate the area under the curve
>
>
> Hi all,
>
> I would like to calculate the area under the ROC curve for my
> predictive
> model. I have managed to plot points giving me the ROC curve.
If x and y are the coordinates of the edges of the polygon
(e.g., polygon(x,y) would draw the polygon) then the polygon's
signed area is given by the following
area<-function(x,y)sum(x*c(y[-1],y[1]) - c(x[-1],x[1])*y)/2
(Positive if edge is traced counter-clockwise.)
This is a discrete version of Green's theorem.
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
> However, I do
> not know how to get the value of the area under.
> Does anybody know of a function that would give the result I
> want using an
> array of specificity and an array of sensitivity as input?
>
> Thanks,
>
> Olivier
> --
> View this message in context:
> http://www.nabble.com/How-to-calculate-the-area-under-the-curv
e-tp26010501p26010501.html
> Sent from the R help mailing list archive at Nabble.com.
>
> ______________________________________________
> R-help at 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.
>
More information about the R-help
mailing list