Re: [R] Density Estimation

From: Rolf Turner <rolf_at_erdos.math.unb.ca>
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

		cheers,

			Rolf Turner
			rolf@math.unb.ca

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.