Weighted kernel density estimator (wKDE)
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.
wKDE(x, eval.points = x, weights = NULL, kernel = "gaussian", bw = "nrd0") mv_wKDE(x, eval.points = x, weights = NULL, kernel = "gaussian")
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
.
### 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 = "")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.