[R] Density Estimation
Rolf Turner
rolf at erdos.math.unb.ca
Wed Jun 7 19:48:06 CEST 2006
Pedro wrote:
> I have made a simple kernel density estimation by
>
> x <- c(2,1,3,2,3,0,4,5,10,11,12,11,10)
> kde <- density(x,n=100)
>
> Now I would like to know the estimated probability that a
> new observation falls into the interval 0<x<3.
>
> How can I integrate over the corresponding interval?
> In several R-packages for kernel density estimation I did
> not found a corresponding function. I could apply
> Simpson's Rule for integrating, but perhaps somebody
> knows a better solution.
One possibility is to use splinefun():
> spiffy <- splinefun(kde$x,kde$y)
> integrate(spiffy,0,3)
0.2353400 with absolute error < 2e-09
cheers,
Rolf Turner
rolf at math.unb.ca
More information about the R-help
mailing list