1

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.

Danica
  • 21,852
  • 1
  • 59
  • 115
JJFM
  • 81
  • 3
  • 2
    It is unclear what you are after here. The question is repetitive, so you could try slimming it down to make it more concise. A kernel must be a density function but you seem to be think that in turn it is being estimated. Some versions of density estimation are based on trying to choose kernel width automatically to optimise some criterion, but in the simplest version of density estimation a kernel width can be something you just choose, depending on whether results seem over-smooth, over-bumpy or about right. – Nick Cox Mar 25 '15 at 10:11
  • 2
    On a different note, using R is incidental to the question. If you want details specific to R implementations, please look at advice in the Help Center on software-related questions. – Nick Cox Mar 25 '15 at 10:13
  • 1
    Does [this answer](http://stats.stackexchange.com/questions/78711/how-to-find-estimate-probability-density-function-from-density-function-in-r/78775#78775) give you what you need? – Glen_b Mar 25 '15 at 10:25
  • Well, sorry if I was not sufficiently clear, I think I've understood now. – JJFM Mar 26 '15 at 17:53
  • 1
    That's good, but without an explicit resolution, it's hard to see this thread being of use to others. – Nick Cox Mar 26 '15 at 19:12
  • I was interested in getting the estimator of the density, thinking that some parameters needed to be evaluated (for example, if you have a linear model Y = a + b*X and data for X and Y, you can estimate a and b and, afterwards, you can make predictions for Y with values of X other than those used to estimate the model), but I understood that the only parameter to compute in the kernel is bandwidth h, therefore once you have h (chosen by yourself or computed by some optimal rule) you have your kernel density formula (the same way once you have a and b you have an implementable linear model). – JJFM Mar 26 '15 at 19:41
  • 1
    OK; note that it's fine here to answer your own question and accept it. – Nick Cox Mar 26 '15 at 23:12

0 Answers0