inst/examples/R/data/nonpara/nadarayawatson/example_nw1.R

library("MASS")  # for Boston Housing data
library("np")
bw <- npregbw(medv~lstat, data=Boston)
mhat <- npreg(bw)
main <- sprintf("%s with h=%.2f", mhat$pckertype, mhat$bw)
plot(Boston$lstat, Boston$medv, pch=19, cex=0.3, main=main)
ind <- order(Boston$lstat)
xs  <- cbind(Boston$lstat, fitted(mhat))[ind,]
lines(xs[,1], xs[,2], col="red", lwd=2)
rug(Boston$lstat)
sigbertklinke/shinyExample documentation built on May 26, 2019, 4:32 a.m.