Cigarette and life expectancy

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,

> base=read.table(
+ "",
+ header=TRUE,sep=",")
> b=base[!$CigCon),]
> plot(b[,5],b[,4],xlab="Cigarette Consumption",
+ ylab="Life Expectancy (at birth)")
> text(b[,5],b[,4]+1,b[,2],cex=.6)
> library(splines)
> X=b[,5]
> Y=b[,4]
> B=data.frame(X,Y)
> reg=glm(Y~bs(X),data=B)
> y=predict(reg,newdata=data.frame(
+ X=seq(0,4000,by=10)))
> lines(seq(0,4000,by=10),y,col="red")

OpenEdition suggests that you cite this post as follows:
Arthur Charpentier (July 28, 2014). Cigarette and life expectancy. Freakonometrics. Retrieved July 18, 2024 from

3 thoughts on “Cigarette and life expectancy”

  1. Another plot:

    ggplot(aes(CigCon,LE,colour=Continent),data=base) + geom_text(aes(label=ifelse(!,as.character(Country),”))) + ylab(‘Life Expectancy (at birth)’) + xlab(‘Cigarette consumption per year’) + geom_smooth(method=’lm’,se=FALSE)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.