views:

48

answers:

2

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:

  1. Specify weights
  2. Specify bandwidth size
  3. Specify bin size

How would you go about this? Bonus points for a code snippet.

+1  A: 

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.

Joris Meys
Thanks for your patience, I'm very much new to the R world and its culture, and its taking a while to learn how things are done here :)
fmark
@fmark: no problem. You can also take a look at this question http://stackoverflow.com/questions/102056/how-to-search-for-r-materials and this question http://stackoverflow.com/questions/192369/books-for-learning-the-r-language
Joris Meys
In answer to your question, a Gaussian smoother will do me nicely, and the `fields` package `smooth.2d` seems to have all the parameters I require.
fmark
+1  A: 

See also the ks package and the nice picture in Multivariate kernel density estimation.

Denis