pluginBw {locpol} | R Documentation |
Plugin Bandwidth selector.
Description
Implements a plugin bandwidth selector for the regression function.
Usage
pluginBw(x, y, deg, kernel, weig = rep(1,length(y)))
Arguments
x |
x covariate values. |
y |
y response values. |
deg |
degree of the local polynomial. |
kernel |
Kernel used to perform the estimation, see |
weig |
Vector of weights for observations. |
Details
Computes the plug-in bandwidth selector as shown in Fan and Gijbels(1996) book using pilots estimates as given in page 110-112 (Rule of thumb for bandwidth selection). Currently, only even values of p are can be used.
Value
A numeric value.
Note
Currently, only even values of p are can be used.
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
Examples
size <- 200
sigma <- 0.25
deg <- 1
kernel <- EpaK
xeval <- 0:100/100
regFun <- function(x) x^3
x <- runif(size)
y <- regFun(x) + rnorm(x, sd = sigma)
d <- data.frame(x, y)
cvBwSel <- regCVBwSelC(d$x,d$y, deg, kernel, interval = c(0, 0.25))
thBwSel <- thumbBw(d$x, d$y, deg, kernel)
piBwSel <- pluginBw(d$x, d$y, deg, kernel)
est <- function(bw, dat, x) return(locPolSmootherC(dat$x,dat$y, x, bw, deg,
kernel)$beta0)
ise <- function(val, est) return(sum((val - est)^2 * xeval[[2]]))
plot(d$x, d$y)
trueVal <- regFun(xeval)
lines(xeval, trueVal, col = "red")
xevalRes <- est(cvBwSel, d, xeval)
cvIse <- ise(trueVal, xevalRes)
lines(xeval, xevalRes, col = "blue")
xevalRes <- est(thBwSel, d, xeval)
thIse <- ise(trueVal, xevalRes)
xevalRes <- est(piBwSel, d, xeval)
piIse <- ise(trueVal, xevalRes)
lines(xeval, xevalRes, col = "blue", lty = "dashed")
res <- rbind( bw = c(cvBwSel, thBwSel, piBwSel),
ise = c(cvIse, thIse, piIse) )
colnames(res) <- c("CV", "th", "PI")
res
[Package locpol version 0.8.0 Index]