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(
+ "http://freakonometrics.free.fr/CigLE.csv",
+ header=TRUE,sep=",")
> b=base[!is.na(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")


3 thoughts on “Cigarette and life expectancy”

  1. Another plot:

    library(ggplot2)
    ggplot(aes(CigCon,LE,colour=Continent),data=base) + geom_text(aes(label=ifelse(!is.na(CigCon),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 *