locpolSmoothers {locpol} | R Documentation |
Local Polynomial estimation.
Description
Computes the local polynomial estimation of the regression function.
Usage
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)
Arguments
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 |
weig |
Vector of weights for observations. |
deg |
Local polynomial estimation degree ( |
DET |
Boolean to ask for the computation of the determinant if the matrix |
Details
All these function perform the estimation of the regression function
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 polynomial estimator for any degree as locPolSmootherC
does, but estimating without using
–th observation on the computation.
Value
A data frame whose components gives the evaluation points, the estimator
for the regression function and its derivatives at each point, and
the estimation of the marginal density for
x
to the power.
These components are given by:
x |
Evaluation points. |
beta0 , beta1 , beta2 , ... |
Estimation of the |
den |
Estimation of |
Author(s)
Jorge Luis Ojeda Cabrera.
References
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).
See Also
locpoly
from package KernSmooth,
ksmooth
and loess
in stats (but from earlier package modreg
).
Examples
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)