######################################################################################################### # # Gross domestic product # # Growth rate compared to previous quarter, seasonally adjusted # Time frame: Q2-2003 to Q4-2012 # ######################################################################################################### # # Hedibert Freitas Lopes # Associate Professor of Econometrics and Statistics # The University of Chicago Booth School of Business # Email: hlopes@chicagobooth.edu # URL: http://faculty.chicagobooth.edu/hedibert.lopes # ######################################################################################################### country = c("Australia","Austria","Belgium","Canada","Chile","Czech Republic", "Denmark","Estonia","Finland","France","Germany","Hungary","Iceland","Ireland", "Israel","Italy","Japan","Korea","Luxembourg","Mexico","Netherlands","New Zealand", "Norway","Poland","Portugal","Slovak Republic","Slovenia","Spain","Sweden", "Switzerland","Turkey","United Kingdom","United States","Argentina","Brazil", "Indonesia","Russian Federation","South Africa") p = length(country) data = scan("GDPgrowth.txt") n = length(data)/p data = matrix(data,p,n,byrow=TRUE) ind = seq(4,39,by=4) pdf(file="GDPgrowth.pdf",width=12,height=10) par(mfrow=c(2,2)) for (i in 1:p){ plot(data[i,],ylim=range(data),xlab="Quarter",ylab="GDP growth",axes=FALSE,type="b",pch=16) axis(2);box();axis(1,at=ind,lab=2004:2012) title(country[i]) } par(mfrow=c(1,1)) plot(data[1,],ylim=range(data),xlab="Quarter",ylab="GDP growth",axes=FALSE,type="b",pch=16) axis(2);box();axis(1,at=ind,lab=2004:2012) for (i in 2:p) lines((1:39)+0.02*i,data[i,],type="b",pch=16) title("GDP growth for 39 countries") par(mfrow=c(1,1)) boxplot.matrix(data,axes=FALSE,xlab="Quarter",ylab="GDP growth") axis(2);box();axis(1,at=ind,lab=2004:2012) title("GDP growth for 39 countries") median = apply(data,2,median) mean = apply(data,2,mean) par(mfrow=c(1,1)) plot(median,ylim=range(median,mean),axes=FALSE,xlab="Quarter",ylab="GDP growth",pch=16) axis(2);box();axis(1,at=ind,lab=2004:2012) points(mean,col=2,pch=16) legend(5,-1,legend=c("Median","Mean"),col=1:2,bty="n",cex=2,pch=16) abline(h=0,lty=3) dev.off()