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$
  • $\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$ – kjetil b halvorsen Oct 4 '19 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$ – kjetil b halvorsen Oct 5 '19 at 16:16
  • 2
    $\begingroup$ Here is a list of common kernel functions $\endgroup$ – user20160 Oct 5 '19 at 17:14
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.

| cite | improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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