kedd-package: Kernel Estimator and Bandwidth Selection for Density and Its...

kedd-packageR Documentation

Kernel Estimator and Bandwidth Selection for Density and Its Derivatives

Description

kedd logo

Kernel smoothing of a univariate density f and of its r-th derivative f^{(r)}:

\hat{f}^{(r)}_h(x) = \frac{1}{n h^{r+1}} \sum_{i=1}^{n} K^{(r)}\!\left(\frac{x - X_i}{h}\right),

with S4 classes, ggplot2 graphics and Rcpp/OpenMP data-driven bandwidth selectors.

Details

Kernels. Every function accepts kernel as one of "gaussian", "epanechnikov", "uniform", "triangular", "biweight", "triweight", "tricube", "cosine", "silverman", "logistic", or a member "pow(s,t)" of the power family K(x)=c_{s,t}(1-|x|^s)^t\mathbf{1}_{|x|\le 1} (see kernel.pow).

Maximum derivative order r for each kernel (see the section below).

Bandwidth selectors (S4 class bandwidth):

h.amise asymptotic MISE (normal reference)
h.ucv unbiased (least-squares) cross-validation
h.bcv biased cross-validation (BCV1, BCV2)
h.ccv complete cross-validation
h.mcv modified cross-validation
h.tcv trimmed cross-validation
h.scv smoothed cross-validation (Gaussian)
h.mlcv maximum-likelihood cross-validation

Estimation and kernels: dkde (S4 class dkde), kernel.fun (K^{(r)}, class kfun), kernel.conv (K^{(r)} * K^{(r)}, class kconv). All classes have show() and ggplot2-based plot() methods; lines() on a bandwidth object returns a layer to add with +.

Parallelism: the O(n^2) criteria run in C++ with OpenMP. The nthreads argument sets the threads of each call: 0 (default) = all processors, k > 0 = k threads, capped by OMP_THREAD_LIMIT; it does not change results nor later calls. Cpp_omp_threads(nthreads) reports the threads actually used.

Data: five samples of size 200 from Marron and Wand (1992) normal mixtures, kurtotic, outlier, bimodal, trimodal and claw (see kedd-data).

Source code and bug reports: https://github.com/ac-guidoum/kedd and https://github.com/ac-guidoum/kedd/issues.

Documentation: a worked introduction is given in vignette("kedd", package = "kedd"), and demonstrations in demo("kedd"), demo("kernels") and demo("bandwidths").

Maximum derivative order

Highest derivative order r (deriv.order) for each kernel. Column 2: K^{(r)} is not identically zero (kernel.fun, kernel.conv, dkde); above it these functions return zero. Columns 3 to 5: the selector criterion is finite; above it the selectors return h = NA with a warning. "any" means no limit and "–" means not available, even at r = 0.

kernel kernel.fun, kernel.conv, dkde UCV, BCV, TCV, AMISE MCV CCV
gaussian any any any any
cosine any 1 0 --
silverman any any any any
logistic 20 8 8 8
epanechnikov 2 1 0 --
uniform 0 0 -- --
triangular 1 0 -- --
biweight 4 2 1 0
triweight 6 3 2 1
tricube 9 3 2 1
pow(s,t) \min(st, 16) \min(r^*, 6) \min(r^*-1, 6) \min(r^*-2, 6)

For pow(s,t), st applies when s and t are integers (16 otherwise), and r^* is the largest integer r < t + 1/2, with 2r \le st when s and t are integers and r < s + 1/2 when s is not an even integer. For example pow(2,3): 6, 3, 2, 1; pow(2,8): 16, 6, 6, 6; pow(1.5,2.5): 16, 1, 0, –. h.scv (Gaussian kernel) has no limit and h.mlcv is for r = 0 only.

Author(s)

Arsalane Chouaib Guidoum acguidoum@univ-tam.dz (author, maintainer), Amel Henider amel.henider@univ-tam.dz (author), Iago Giné-Vázquez iago.gin-vaz@protonmail.com (contributor).

References

Guidoum, A. C. (2020). Kernel estimator and bandwidth selection for density and its derivatives: the kedd package. arXiv:2012.06102.

Marron, J. S. and Wand, M. P. (1992). Exact mean integrated squared error. The Annals of Statistics, 20, 712–736.

Wand, M. P. and Jones, M. C. (1995). Kernel Smoothing. Chapman and Hall, London.

See Also

dkde, kernel.fun, kernel.conv, kernel.pow, h.ucv, h.scv, bandwidth, kedd-data, vignette("kedd"), citation("kedd").

Examples

x <- rnorm(150)
bw <- h.ucv(x, kernel = "biweight")
bw
plot(dkde(data = x, h = bw@h, kernel = "biweight"))

## logistic and power kernels
h.bcv(x, whichbcv = 2, kernel = "logistic")
h.bcv(x, whichbcv = 2, kernel = kernel.pow(2, 4))

kedd documentation built on Nov. 12, 2026, 5:10 p.m.