Discrete Kernel Density Estimator
estim_kernel(
kernel = c("optimal", "triang", "epanech", "binomial"),
x,
h,
v,
k = NULL
)
the type of kernel. Currently supported kernels are limited to: "optimal", "triang", "epanech" and "binomial"
the list of target points at which the density is calculated
the bandwidth (or smoothing parameter)
the vector of observations
Optional: the integer (positive) parameter that defined the support of the kernel function (corresponds to parameter 'a' for triangular kernel). It is only used for optimal and triangular kernel
The estimated discrete kernel density values
n <- 250
mu <- 2 # Mean
x <- 0:10 # target values
y <- sort(rpois(n, mu)) # simulated Poisson observations
# kernel parameters
kernel <- "optimal"
k <- 1
# Cross Validation
H <- seq((max(y) - min(y)) / 200, (max(y) - min(y)) / 2, length.out = 50)
hcv <- cv_bandwidth(kernel = kernel, y, h = H, k = k)
# Kernel estimation
fn_opt_k <- estim_kernel(kernel = kernel, x = x, h = hcv, v = y, k = k)