0

Setup

library("DiagTest3Grp", lib.loc="~/R/win-library/3.2")
data <- c(34,46,47,48,52,53,55,56,56,56,57,58,59,59,68)
bw <- BW.ref(data)
x0 <- seq(0, 100, .1) 
KS.cdfvec <- Vectorize(KernelSmoothing.cdf, vectorize.args = "c0")
x0.cdf <- KS.cdfvec(xx = data, c0 = x0, bw = bw)
plot(x0, x0.cdf, type = "l")

Produces a Cumulative Graph. I'd like to know how to derive area under the curve given any x

Rich Scriven
  • 97,041
  • 11
  • 181
  • 245
thistleknot
  • 1,098
  • 16
  • 38
  • 1
    Like this does? http://stackoverflow.com/questions/4954507/calculate-the-area-under-a-curve-in-r – Rich Scriven May 03 '16 at 19:43
  • i've looked at that as well as another post (http://stackoverflow.com/questions/36944874/r-area-under-curve-of-ogive) and I don't see how they would derive it using a plot as a base. Maybe the answer is here and I'm just not sure how to complete it: AUC <- sum(diff(x[id])*rollmean(y[id],2)) – thistleknot May 03 '16 at 20:05
  • 1
    How about for values less than 60, `w <- x0<60; sum(diff(x0[w]) * zoo:::rollmean(x0.cdf[w], 2))` – MrFlick May 03 '16 at 22:24
  • Have you tried the "integrate" command with the x0.cdf? – Dave2e May 03 '16 at 22:30
  • I was looking at that function earlier. I see a lot of "different" way to perform integration, but not on some predefined lineplot. How would I feed f into integrate? Is f replaced with x0.cdf? Say I'm trying to integrate between 40 and 60 using x0.cdf how would one go about it? I see there are a lot of options to integrate, here's another page (http://stackoverflow.com/questions/24563061/computing-integral-of-a-line-plot-in-r) – thistleknot May 03 '16 at 23:59
  • Thank you MrFlick! If you want to submit this as an answer I'll upvote it – thistleknot May 04 '16 at 00:08

0 Answers0