1
$\begingroup$

I'm writing an R function to get the fitted values of the kernel density estimate. For that I use the computational formula of summation of ({n-1 h-1 K{(x - Xi)/h}}?) $$ \hat{f}(x) = \frac1{n h}\sum_{i=1}^n K\left(\frac{x-X_i}{h}\right) $$ where $n$ is the number of observations and $h$ is the bandwidth. Here $K$ is supposed to be the kernel function, but I don't find a clear formula to plug-in for $K$ in this formula.

I'm known that there are various kernel functions, but I clearly couldn't find the list of kernel functions that exist. (Epanechnikov kernel, cosine, Gaussian, Parzen, rectangular, and triangle kernels are among).

Could someone kindly provide me with a/some straightforward formulas to obtain K?

I used the following article:

DENSITY ESTIMATION FOR STATISTICS AND DATA ANALYSIS B.W. Silverman School of Mathematics University of Bath, UK.

$\endgroup$
3
  • $\begingroup$ Well, you really need to learn $\LaTeX$ (and its version implemented here in Mathjax, see math.meta.stackexchange.com/questions/5020/…. As for me doing it, lack of parenthesis makes the intention unclear to me, so will not try. At least edit to make the meaning of the formals clear! $\endgroup$ Commented Oct 4, 2019 at 9:34
  • $\begingroup$ I guessed that you want formula 2.2a from the linked paper. Can you verify? Also, now push the edit button, look at the $\LaTeX$, and learn! $\endgroup$ Commented Oct 5, 2019 at 16:16
  • 2
    $\begingroup$ Here is a list of common kernel functions $\endgroup$
    – user20160
    Commented Oct 5, 2019 at 17:14

1 Answer 1

1
$\begingroup$

$K$ is just something you pick as part of the model. The standard choices are indeed Gaussian, Epanechnikov, rectangular, etc. Exactly which properties $K$ needs to satisfy will depend on what properties you want, but the general baseline is just that:

  • $\int K(x) \, dx = 1$ so that the overall estimate integrates to 1;
  • usually $K(x) \ge 0$ so that, combined with the previous one, the overall estimate is a valid density;
  • usually $K(-x) = K(x)$ for simplicity.

You're not going to be able to write all of this in your code, but you can implement the most common ones and possibly allow for a user-specified one in some way.

@user20160 posted a useful catalog of the most common choices while I was writing this.

$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.