{"word_count": 101, "character_count": 940}
Yesterday evening, I uploaded a graph, with the labor productivity as a function of coffee consumption. Of course, it was for fun ! With this kind of regression, base on aggregated data, we can say almost anything, since most of them are correlated because of some (hidden) common factor, such as the wealth of the country. For instance, with a similar approach, we can see that there is an increasing relationship, when looking at life expectancy as a function of cigarette consumption,&#62; base=read.table(+ "http://freakonometrics.free.fr/CigLE.csv",+ header=TRUE,sep=",")&#62; b=base[!is.na(base$CigCon),]&#62; plot(b[,5],b[,4],xlab="Cigarette Consumption",+ ylab="Life Expectancy (at birth)")&#62; text(b[,5],b[,4]+1,b[,2],cex=.6)&#62; library(splines)&#62; X=b[,5]&#62; Y=b[,4]&#62; B=data.frame(X,Y)&#62; reg=glm(Y~bs(X),data=B)&#62; y=predict(reg,newdata=data.frame(+ X=seq(0,4000,by=10)))&#62; lines(seq(0,4000,by=10),y,col="red")