An implementation of the cross-validation principle for the bandwidth selection as presented in Strothmann, Dette and Siburg (2022) <arXiv:2201.03329>.
computeBandwidth(X, sL, sU, method = c("cvsym", "cvasym"), reduce = TRUE)
The chosen bandwidth depending on the data.frame X.
A bivariate data.frame containing the observations. Each row contains one observation.
Lower bound \(N^{sL}\) for the possible bandwidth parameters (where \(N\) is the number of observations).
Upper bound \(N^{sU}\) for the possible bandwidth parameters (where \(N\) is the number of observations).
"cvsym" uses either a symmetric cross-validation principle (N_1 = N_2) and "cvasym" uses an asymmetric cross-validation principle (i.e. \(N_1\) and \(N_2\) may attain different values).
In case reduce is set to TRUE, the parameter is chosen from N, N+2, ... instead of N, N+1, N+2, ...
This function computes the optimal bandwidth given the bivariate observations \(X\) of length \(N\). Currently, there are two different algorithms implemented:
"cvsym" - Computes the optimal bandwidth choice for a square checkerboard mass density according to the cross-validation principle. The bandwidth is a natural number between \(N^{sL}, ..., N^{sU}\)
"cvasym" - Computes the optimal bandwidth choice \((N_1, N_2)\) for a non-square checkerboard mass density according to the cross-validation principle. The bandwidths \(N_1, N_2\) are natural numbers between \(N^{sL}, ..., N^{sU}\) and may possibly attain different values.
n <- 20
X <- cbind(runif(n), runif(n))
computeBandwidth(X, sL = 0.25, sU = 0.5, method="cvsym", reduce=TRUE)
Run the code above in your browser using DataLab