Re: [R] Density Estimation

From: Rolf Turner <>
Date: Thu 08 Jun 2006 - 03:48:06 EST

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


			Rolf Turner

______________________________________________ mailing list PLEASE do read the posting guide! Received on Thu Jun 08 03:56:17 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Thu 08 Jun 2006 - 06:10:51 EST.

Mailing list information is available at Please read the posting guide before posting to the list.