library(np)
library(mlbench)
data(BostonHousing)
s <- sort(BostonHousing[,13], index.return=T)
x <- BostonHousing[s$ix,13]
y <- BostonHousing[s$ix,14]
lr <- lm (y~x)
nw <- npreg(y~x)
yh <- fitted(nw)
se <- se(nw)
uc <- fitted(nw)+1.96*se
lc <- fitted(nw)-1.96*se
png("NW_cb.png")
plot(x, y, xlab="Anteil der Unterschichtbevölkerung pro Bezirk (in %)", ylab="Mittlerer Hauspreis pro Bezirk (in 1000 US$)", main="Boston Housing Daten", cex=0.5)
abline(lr, lwd=2)
lines(x, fitted(nw), lwd=2, col="red")
lines(x, uc, lwd=1, col="red")
lines(x, lc, lwd=1, col="red")
dev.off()
Licensing
Public domainPublic domainfalsefalse
I, the copyright holder of this work, release this work into the public domain. This applies worldwide. In some countries this may not be legally possible; if so: I grant anyone the right to use this work for any purpose, without any conditions, unless such conditions are required by law.
{{Information |Description={{en|1=Nadaraya Watson estimator with optimal bandwidth and pointwise confidence band and linear regression estimator.}} {{de|1=Lineare Regression und Nadaraya Watson Schätzer mit optimaler Bandweite und punktweisen Konfidenzba