Learn R Programming

kernopt (version 1.0.0)

cv_bandwidth: 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
)

Value

the optimal bandwidth value

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

Examples

Run this code
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)

Run the code above in your browser using DataLab