I would like to produce a kernel density estimation in R, and am somewhat bamboozled by all the different packages. I need to be able to:
How would you go about this? Bonus points for a code snippet.
The KDE is calculated by weighting the distances of all the data points we've seen for each location on the blue line. If we've seen more points nearby, the estimate is higher, indicating that probability of seeing a point at that location.
What is Kernel Density Estimation? Kernel density estimation is a non-parametric method of estimating the probability density function (PDF) of a continuous random variable. It is non-parametric because it does not assume any underlying distribution for the variable.
In statistics, kernel density estimation (KDE) is the application of kernel smoothing for probability density estimation, i.e., a non-parametric method to estimate the probability density function of a random variable based on kernels as weights.
The method of kernel density estimation can be readily used for the purposes of classification, and an easy-to-use package (alloc80) is now in wide circulation. It is known that this method performs well (at least in relative terms) in the case of bimodal, or heavily skewed distributions.
See also the ks package and the nice picture in Multivariate kernel density estimation.
Off course there's a number of packages. You should first decide which 2D kernel estimate you want. In the fields package you have a function smooth.2d, and you have the wonderful package of Brian Ripley, KernSmooth. The extra points for the code snippets you can give to the help files, I ain't going to copy them.
For these kind of questions, also try www.rseek.org.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With