## ---------------------------------------------------------------------------- ## R scripts for Haerdle/Mueller/Sperlich/Werwatz: "Nonparametric and ## Semiparametric Modelling", Springer Series in Statistics, 2004 ## ---------------------------------------------------------------------------- ## Script SPMlocpolyregression ## ---------------------------------------------------------------------------- ## Description computes the regression of food on net-income ## for the UK 1976 expenditure data. ## ---------------------------------------------------------------------------- ## Author Marlene Mueller, 2008/12/19 ## ---------------------------------------------------------------------------- x <- read.csv2("D:\\fes76.txt", dec=".") x <- x[,c("NIC","FOO")] x <- x[order(x$NIC),] plot(x,col="cyan",pch=20,main="Engel Curve") library(KernSmooth) mh <- locpoly(x$NIC,x$FOO,degree=0,kernel="normal",bandwidth=20) lines(mh) mh1 <- locpoly(x$NIC,x$FOO,degree=1,kernel="normal",bandwidth=20) lines(mh1,col="blue",lwd=2) legend("topright",c("NadWat","LocLin"),col=c("black","blue"),lwd=c(1,2))