Learn R Programming

iosmooth (version 0.94)

ioksmooth: 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 x.
y
Response variable y.
bw
The kernel bandwidth. Can be chosen with the help of bwplot.
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 is not specified.
x.points
The points at which the density should be calculated. If missing, the function defaults to the range of x +/- 5%.

Value

A list of length 2 A list of length 2

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.

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

bwplot, bwplot.numeric

Examples

Run this code
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")

Run the code above in your browser using DataLab