Skip to contents

At each evaluation point x0 solves the kernel-weighted least squares problem (ESL Eq. 6.11) on the centered polynomial design [1, (x - x0), ..., (x - x0)^d]; the fitted value is the local intercept and the local slope is the coefficient of (x - x0). Degree-d polynomials are reproduced exactly for any kernel and bandwidth.

Usage

morie_locp(x, y, x0 = NULL, degree = 1, bandwidth = NULL, kernel = "tricube")

Arguments

x, y

Paired numeric observations.

x0

Optional numeric vector of evaluation points (default: sorted unique x).

degree

Polynomial degree d >= 0.

bandwidth

Kernel half-width (default: half the x range).

kernel

"tricube" (default), "epanechnikov" or "gaussian".

Value

A list with elements fitted, x0, slope, n_effective, degree, bandwidth, kernel, method.

References

Fan, J. and Gijbels, I. (1996). Local Polynomial Modelling and Its Applications. Chapman & Hall. Hastie, T., Tibshirani, R. and Friedman, J. (2009). The Elements of Statistical Learning, 2nd ed. Springer, Sec. 6.1.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_locp(V, V)
#> $fitted
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $x0
#> [1] 1 2 3 4 5 6 7 8
#> 
#> $slope
#> [1] 1 1 1 1 1 1 1 1
#> 
#> $n_effective
#> [1] 2.520593 3.452241 3.990424 4.041185 4.041185 3.990424 3.452241 2.520593
#> 
#> $degree
#> [1] 1
#> 
#> $bandwidth
#> [1] 3.5
#> 
#> $kernel
#> [1] "tricube"
#> 
#> $method
#> [1] "local polynomial WLS (Fan-Gijbels 1996; ESL Eq. 6.11)"
#>