Skip to contents

Avoids the boundary bias of Nadaraya-Watson by fitting a local linear model at each evaluation point.

Usage

local_linear(x, y, x_eval, bandwidth, return_slope = FALSE)

Arguments

x

Numeric covariate vector.

y

Numeric outcome vector.

x_eval

Evaluation grid.

bandwidth

Positive bandwidth.

return_slope

Logical; if TRUE, also return local slopes.

Value

If return_slope = FALSE, a numeric vector of fitted values; otherwise a list with y_hat and beta_hat.

References

Fan, J. and Gijbels, I. (1996). Local Polynomial Modelling and Its Applications. Chapman and Hall.