Minimises CV(h) equal to one over n times sum over i of
(Y_i minus m-hat-h-minus-i of X_i) squared on a grid spanning
bw_min to bw_max.
Usage
loocv_bandwidth(x, y, bw_min = NULL, bw_max = NULL, n_grid = 30L)
Arguments
- x
Numeric covariate vector.
- y
Numeric outcome vector.
- bw_min
Minimum candidate bandwidth (defaults to
0.1 times the Silverman bandwidth).
- bw_max
Maximum candidate bandwidth (defaults to
2.0 times the Silverman bandwidth).
- n_grid
Number of candidate values.
Value
Optimal bandwidth (numeric scalar).
References
Hardle, W. (1990). Applied Nonparametric Regression.
Cambridge.
Examples
set.seed(1)
x <- sort(runif(15, -2, 2))
y <- sin(x) + 0.2 * rnorm(15)
h <- loocv_bandwidth(x, y, n_grid = 5L)
h
#> [1] 0.3572348