Re: [R] question on graphs and finding area under a curve

2005-08-03 Thread Adaikalavan Ramasamy
Also see function rocdemo.sca in the ROC package. The area under the 45 degree line in an ROC curve has an area of 0.5. Regards, Adai On Tue, 2005-08-02 at 09:24 -0400, Ravi Varadhan wrote: Hi, To find the area lying between the curve y = y(x) and 45 degree line (which, assuming it goes

[R] question on graphs and finding area under a curve

2005-08-02 Thread Renuka Sane
Question on graphs: The default case for drawing a graph in R, is where a little space is left on the x and y axis before the first tick i.e. even if I say xlim=c(0,1) -- there will be some space between the edge of the x-axis and where 0 is placed. If I want 0 on the edge, how do I do it in

Re: [R] question on graphs and finding area under a curve

2005-08-02 Thread Marc Schwartz
On Tue, 2005-08-02 at 18:20 +0530, Renuka Sane wrote: Question on graphs: The default case for drawing a graph in R, is where a little space is left on the x and y axis before the first tick i.e. even if I say xlim=c(0,1) -- there will be some space between the edge of the x-axis and where

Re: [R] question on graphs and finding area under a curve

2005-08-02 Thread Romain Francois
Le 02.08.2005 14:50, Renuka Sane a écrit : Question on graphs: The default case for drawing a graph in R, is where a little space is left on the x and y axis before the first tick i.e. even if I say xlim=c(0,1) -- there will be some space between the edge of the x-axis and where 0 is placed.

Re: [R] question on graphs and finding area under a curve

2005-08-02 Thread Tuszynski, Jaroslaw W.
How about: trapz = function(x, y) { # computes the integral of y with respect to x using trapezoidal integration. idx = 2:length(x) return (as.double( (x[idx] - x[idx-1]) %*% (y[idx] + y[idx-1])) / 2) } Jarek \=== Jarek Tuszynski,

Re: [R] question on graphs and finding area under a curve

2005-08-02 Thread Ravi Varadhan
Hi, To find the area lying between the curve y = y(x) and 45 degree line (which, assuming it goes through the origin, is y = x), you can use the following function based on trapezoidal rule: trap.rule - function(x,f) {sum(diff(x)*(f[-1]+f[-length(f)]))/2} trap.rule(x,f=y-x) This area will be