ioksmooth {iosmooth} | R Documentation |
Nadaraya-Watson regression estimator with infinite order kernels.
Description
Calculates the Nadaraya-Watson nonparametric kernel regression estimator using infinite order flat-top kernels. These estimators have been shown to automatically achieve optimal rates of covergence across a wide range of scenarios.
Usage
ioksmooth(x, y, bw = 0.1, kernel = c("Trap", "Rect", "SupSm"), n.points = 100, x.points)
Arguments
x |
Predictor variable |
y |
Response variable |
bw |
The kernel bandwidth. Can be chosen with the help of |
kernel |
Three flat-top kernels are implemented, described by the shape of their Fourier transforms. "Trap" is trapezoid shaped and is the default. The rectangular kernel is not recommended and is here for comparison only. SuperSmooth is infinitely differentiable in the Fourier domain, which, in theory, minimizes edge effects in the interior of the domain. It is calculated numerically, and will be slower. |
n.points |
The number of points at which the density estimate will be calculated if |
x.points |
The points at which the density should be calculated. If missing, the function defaults to the range of |
Value
A list of length 2
x |
The |
y |
The estimated regression function at the associated x values. |
Warning
The regressions can be unstable in regions where the design density is low. For regression, bwplot
can be used to visually select the large low frequency component, but it is not amenable to algorithmic bandwidth choice.
Author(s)
Timothy L. McMurry
References
McMurry, T. L., & Politis, D. N. (2004). Nonparametric regression with infinite order flat-top kernels. Journal of Nonparametric Statistics, 16(3-4), 549-562.
McMurry, T. L., & Politis, D. N. (2008). Minimally biased nonparametric regression and autoregression. REVSTAT-Statistical Journal, 6(2), 123-150.
See Also
Examples
set.seed(123)
x <- sort(runif(200, 0, 2*pi))
# Regression function
r <- exp(-x^2) + sin(x)
# Observed response
y <- r + 0.3*rnorm(200)
bwplot(x, y, smax=10)
# Choose bandwidth about 1/2
plot(x, y)
lines(ioksmooth(x, y, bw=1/2, kernel="Trap"))
# Add the truth in red
lines(x, r, col="red")