locpol {locpol} | R Documentation |
Computes the local polynomial estimation of the regression function.
locCteSmootherC(x, y, xeval, bw, kernel, weig = rep(1, length(y))) locLinSmootherC(x, y, xeval, bw, kernel, weig = rep(1, length(y))) locCuadSmootherC(x, y, xeval, bw, kernel, weig = rep(1, length(y))) locPolSmootherC(x, y, xeval, bw, deg, kernel, DET = FALSE, weig = rep(1, length(y))) looLocPolSmootherC(x, y, bw, deg, kernel, weig = rep(1, length(y)), DET = FALSE)
x |
x covariate data values. |
y |
y response data values. |
xeval |
Vector of evaluation points. |
bw |
Smoothing parameter, bandwidth. |
kernel |
Kernel used to perform the estimation, see Kernels |
weig |
Vector of weigths for observations. |
deg |
Local polynomial estimation degree($p$). |
DET |
Boolean to ask for the computation of the determinant if the matrix $X^TWX$. |
All these function perform the estimation of the regression funciton
for different degrees. While locCteSmootherC
, locLinSmootherC
,
and locCuadSmootherC
uses direct computations for the degrees 0,1
and 2 respectively, locPolSmootherC
implements a general method for any degree.
Particularly useful can be looLocPolSmootherC
(Leave one out) which computes the local polinomial estimator for any degree as locPolSmootherC
does, but estimating m(x_i) without usign ith observation on tne computation.
A data frame whose components gives the evaluation points, the estimator
for the regression function $m(x)$ and its derivatives at each point, and
the estimation of the marginal density for x
to the $p+1$ power.
These components are given by:
x |
Evaluation points. |
beta0, beta1, beta2,... |
Estimation of the $i$-th derivative of the regression function($m^{(i)}(x)$) for $i=0,1,...$. |
den |
Estimation of $(n*bw*f(x))^{p+1}$. |
Jorge Luis Ojeda Cabrera.
Fan, J. and Gijbels, I. Local polynomial modelling and its applications/. Chapman & Hall, London (1996).
Wand, M.~P. and Jones, M.~C. Kernel smoothing/. Chapman and Hall Ltd., London (1995).
locpoly
from package KernSmooth,
ksmooth
and loess
from package modreg.
N <- 100 xeval <- 0:10/10 d <- data.frame(x = runif(N)) bw <- 0.125 fx <- xeval^2 - xeval + 1 ## Non random d$y <- d$x^2 - d$x + 1 cuest <- locCuadSmootherC(d$x, d$y ,xeval, bw, EpaK) lpest2 <- locPolSmootherC(d$x, d$y , xeval, bw, 2, EpaK) print(cbind(x = xeval, fx, cuad0 = cuest$beta0, lp0 = lpest2$beta0, cuad1 = cuest$beta1, lp1 = lpest2$beta1)) ## Random d$y <- d$x^2 - d$x + 1 + rnorm(d$x, sd = 0.1) cuest <- locCuadSmootherC(d$x,d$y , xeval, bw, EpaK) lpest2 <- locPolSmootherC(d$x,d$y , xeval, bw, 2, EpaK) lpest3 <- locPolSmootherC(d$x,d$y , xeval, bw, 3, EpaK) cbind(x = xeval, fx, cuad0 = cuest$beta0, lp20 = lpest2$beta0, lp30 = lpest3$beta0, cuad1 = cuest$beta1, lp21 = lpest2$beta1, lp31 = lpest3$beta1)