I'm pretty new to statistics so please excuse me if the answer is obvious.
The scenario is the following: I am using mcmc to sample from a posterior distribution of a parameter. I then need to estimate a quantity that depends on that parameter by integrating with respect to the posterior distribution of the parameter.
My question is, how can I get a density function from a sample of 500 points? I know I can get the cdf and the density is the derivative of it but I am unsure about how to do all of this in R.
Thanks!
EDIT:
One approach I was thinking about is to discretize the distribution and do a sum instead of an integral, but I'm wondering if there is a better way.