## ---------------------------------------------------------------------------- ## R scripts for Haerdle/Mueller/Sperlich/Werwatz: "Nonparametric and ## Semiparametric Modelling", Springer Series in Statistics, 2004 ## ---------------------------------------------------------------------------- ## Script SPMsplineregression ## ---------------------------------------------------------------------------- ## 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="lightblue",pch=20,main="Engel Curve: Spline regression") library(splines) mh <- smooth.spline(x$NIC, x$FOO, df=10) lines(x$NIC,fitted(mh))