Useful for the conditional outcome stage of TMLE / AIPW.
Examples
set.seed(1)
x <- sort(runif(40, -2, 2))
y <- sin(x) + 0.2 * rnorm(40)
x_eval <- seq(-1.5, 1.5, length.out = 20)
r <- kernel_cond_moments(x, y, x_eval, bandwidth = 0.5,
return_variance = TRUE)
r$mean
#> [1] -0.91406954 -0.88024411 -0.83068530 -0.76548589 -0.68605210 -0.59413791
#> [7] -0.49015136 -0.37206368 -0.23650553 -0.08252016 0.08401605 0.24988925
#> [13] 0.40055040 0.52769384 0.63127532 0.71593588 0.78660598 0.84619571
#> [19] 0.89546439 0.93412154
