NW.kernel(haerdle) | R Documentation |
Nadaraya-Watson non-parametric regression
NW.kernel(x, y, h, kernel=4, points=100, na.handling=0)
x |
data vector |
y |
data vector |
h |
bandwidth |
kernel |
code for kernel. 1 = uniform, 2 = triangle (ASH), 3 = Epanchenikov, 4 = quartic, 5 = triweight, 6 = Gaussian, 7 = cosinus |
points |
number of points to evaluate curve over the data range |
na.handling |
How to handle 0/0. If 1 forces 0/0 = 0. |
list with components grid, m (fitted curve), x and y
`Smoothing Techniques with Implementation in S', Wolfgang Haerdle, Springer, 1991
data(faithful) # Figure 5.3 plot(faithful$eruptions,faithful$waiting) nw<-NW.kernel(faithful$eruptions, faithful$waiting, 0.1) lines(nw$grid, nw$m) nw<-NW.kernel(faithful$eruptions, faithful$waiting, 0.4) lines(nw$grid, nw$m, lty=2) nw<-NW.kernel(faithful$eruptions, faithful$waiting, 0.8) lines(nw$grid, nw$m, lty=3) data(dat.reg) # Figure 5.4 plot(dat.reg) lines(dat.reg$x, dat.reg$m) nw<-NW.kernel(dat.reg$x, dat.reg$y, 0.05) lines(nw$grid, nw$m, lty=2) nw<-NW.kernel(dat.reg$x, dat.reg$y, 0.10) lines(nw$grid, nw$m, lty=3)