I am working on a density estimation project and I need to get an estimation of the density as well as an equation for the density estimator (and not the estimate).
I am working with kernel estimators, and for that, I am using the density
function, which gives me an estimation of the density given the data I have inputted.
I am new to non-parametric statistics and kernel estimation, therefore I am not fully comfortable with kernels, so maybe my question might be a bit dull.
As I explained, I need both an estimation of the density (which I can then plot; this I have been able to do it with density
) as well as the density estimator (i.e. the equation, the formula), but I have been unable to achieve this with density
function. Do you know how can I get the formula, i.e. the value of the parameters that determine it ?
On the other side, I might not need R to infer the equation. Indeed, if I am not mistaken, given I am working with a Gaussian kernel, I have the following estimator for the density :
$\hat f(x) = \frac{1}{nh} \sum\limits_{i=1}^n K(\frac{x-x_i}{h}) = \frac{1}{nh\sqrt {2\pi}} \sum\limits_{i=1}^n e^{-\frac{1}{2}(\frac{x-x_i}{h})^2}$
I think I have all I need there without requiring R's help any further, haven't I? I know $n$ as well as my sample $(x_1,...,x_n)$; $h$ has been computed by R or equivalently determined by some optimal rule. Thus, to get an estimation for some $x$ which does not belong to $(x_1,...,x_n)$ I just have to input it into $\hat f(.)$, isn't it? Or am I missing something?
Thank you for your help.