Discrete Kernel Density Estimator

estim_kernel(
  kernel = c("optimal", "triang", "epanech", "binomial"),
  x,
  h,
  v,
  k = NULL
)

Arguments

kernel

the type of kernel. Currently supported kernels are limited to: "optimal", "triang", "epanech" and "binomial"

x

the list of target points at which the density is calculated

h

the bandwidth (or smoothing parameter)

v

the vector of observations

k

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

Value

The estimated discrete kernel density values

Examples

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)