Re: [R] Density Estimation

From: Greg Snow <>
Date: Thu 08 Jun 2006 - 03:21:51 EST

Not a direct answer to your question, but if you use a logspline density estimate rather than a kernal density estimate then the logspline package will help you and it has built in functions for dlogspline, qlogspline, and plogspline that do the integrals for you.

If you want to stick with the KDE, then you could find the area under each of the kernals for the range you are interested in (need to work out the standard deviation used from the bandwidth, then use pnorm for the default gaussian kernal), then just sum the individual areas.

Hope this helps,

Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
(801) 408-8111

-----Original Message-----
[] On Behalf Of Pedro Ramirez
Sent: Wednesday, June 07, 2006 11:00 AM
Subject: [R] Density Estimation

Dear R-list,

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.

Thanks a lot for help!



______________________________________________ mailing list PLEASE do read the posting guide!
______________________________________________ mailing list PLEASE do read the posting guide!
Received on Thu Jun 08 04:36:05 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.