cv_bandwidth: Cross-Validation function for bandwidth parameter selection...

View source: R/cv_bandwidth.r

cv_bandwidthR Documentation

Cross-Validation function for bandwidth parameter selection of discrete kernel

Description

Cross-Validation function for bandwidth parameter selection of discrete kernel

Usage

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

Arguments

kernel

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

v

the vector of observations

h

the list of bandwidth parameters to test in cross validation

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 optimal bandwidth value

Examples

n <- 250
mu <- 2 # Mean
y <- sort(rpois(n, mu))
# kernel support parameter
k <- 1
H <- seq((max(y) - min(y)) / 200, (max(y) - min(y)) / 2, length.out = 50)
hcv <- cv_bandwidth(kernel = "optimal", y, h = H, k = k)

kernopt documentation built on April 3, 2025, 9:34 p.m.