Kernel Density Estimation

Does STAN have functionality to do KDE? If so, how would I implement it?

Not built in. You could write your own function (note that this returns the unnormalised log pdf), but I really wouldn’t recommend it. It’s very slow, and interacts poorly with HMC.


I think your question might be more broadly suited towards Bayesian nonparametric modeling. Chapters 21 and 23 of Bayesian Data Analysis (Gelman et al., free pdf for personal use) discuss latent Gaussian process and Dirichlet processes for density estimation. This is pretty far from my area of personal expertice but I did find an earlier thread on the forums (Bayesian nonparametric modeling - #16 by arya) discussing why Stan may or may not be your best choice.

There’s also Ben Goodrich’s work on density-free inference.