[R] Density Estimation

Pedro Ramirez pramirez379 at hotmail.com
Wed Jun 7 19:54:32 CEST 2006

>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,

Thanks a lot for your quick help! I think I will follow your first 
suggestion (logspline
density estimation) instead of summing over the kernel areas because at the
boundaries of the range truncated kernel areas can occur, so I think it is
easier to do it with logsplines. Thanks again for your help!!


>Gregory (Greg) L. Snow Ph.D.
>Statistical Data Center
>Intermountain Healthcare
>greg.snow at intermountainmail.org
>(801) 408-8111
>-----Original Message-----
>From: r-help-bounces at stat.math.ethz.ch
>[mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Pedro Ramirez
>Sent: Wednesday, June 07, 2006 11:00 AM
>To: r-help at stat.math.ethz.ch
>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!
>R-help at stat.math.ethz.ch mailing list
>PLEASE do read the posting guide!

More information about the R-help mailing list