wKDE
gives a (weighted) kernel density estimate
(KDE) for univariate data.
If weights are not provided, all samples count equally.
It evaluates on new data point by interpolation (using
approx
).
mv_KDE
uses the locfit.raw
function in the locfit package to estimate KDEs for
multivariate data. Note: Use this only for small
dimensions, very slow otherwise.
1 2 3 
x 
data vector 
eval.points 
points where the density should be
evaluated. Default: 
weights 
vector of weights. Same length as

kernel 
type of kernel. Default:

bw 
bandwidth. Either a character string indicating
the method to use or a real number. Default:

A vector of length length(eval.points)
(or
nrow(eval.points)
) with the probabilities of each
point given the nonparametric fit on x
.
1 2 3 4 5 6 7 8 9 10 11 12  ### Univariate example ###
xx < sort(c(rnorm(100, mean = 1), runif(100)))
plot(xx, wKDE(xx), type = "l")
yy < sort(runif(50, 1, 4)  1)
lines(yy, wKDE(xx, yy), col = 2)
### Multivariate example ###
XX < matrix(rnorm(100), ncol = 2)
YY < matrix(runif(40), ncol = 2)
dens.object < mv_wKDE(XX)
plot(dens.object)
points(mv_wKDE(XX, YY), col = 2, ylab = "")

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.