Skip to content

density function

3 messages · pilaw, Rui Barradas, Greg Snow

#
Hello,

I need density function so that I can find expected value (using
integration). I use density():
f= density(data)
but f isn't a function and I can't get values and integrate it
This is very urget, so please help.  

Greetings
Peter

--
View this message in context: http://r.789695.n4.nabble.com/density-function-tp4634563.html
Sent from the R help mailing list archive at Nabble.com.
#
Hello,

Maybe the link below is of some use.

http://stats.stackexchange.com/questions/14061/area-under-the-pdf-in-kernel-density-estimation-in-r

Hope this helps,

Rui Barradas


Em 27-06-2012 01:13, pilaw escreveu:
#
Here are 2 approaches:

Use logspline density estimates (logspline package) rather than kernel
density estimates, this can give you a function to pass to integrate
or other tools, the estimates may be a little different from the
kernel density estimates.

If you need to use kernel density estimates, then realize that the kde
is just the sum of 1/n times the kernel centered at each of the n
points.  And the integral of a sum is the sum of the integrals (and
the 1/n can be factored out), so you can just integrate each of the n
kernals (centered at the datapoints with proper width), then sum and
divide by n (or take the mean).
On Tue, Jun 26, 2012 at 6:13 PM, pilaw <pilawski.p at gmail.com> wrote: