Finance, Foreign (Direct) Investment and Dutch Disease

This documents allows to replicate all figures and econometric results for the paper โ€œFinance, Foreign (Direct) Investment and Dutch Diseaseโ€.

First, we need to install two packages: Dynamic Systems Estimation (dse) and Testing, Monitoring, and Dating Structural Changes (strucchange). If you have already istalled that package, you may skip this part.

install.packages(pkgs = c("dse","strucchange"))

Then, load these packages. Plus create three functions allowing for HP filtering and HP predictions.

library(dse)
library(strucchange)
hpfilter <- function(x,lambda=6.25){ 
  eye <- diag(length(x)) 
  result <- solve(eye+lambda*crossprod(diff(eye,lag=1,d=2)),x) 
  return(result) 
  } 

predHP<-function(xHP){
  predx<-2*xHP[length(xHP)]-xHP[length(xHP)-1]
  return(predx)
  }

buildHPSeries <- function(x){
  indexes<-which(!is.na(x),arr.ind=TRUE)
  if(length(indexes)<=10){
    stop("Trying to build a trended HP series with less than 10 observations")
    }
  result=matrix(nrow=1,ncol=length(x))
  for(i in 1:10){
    result[indexes[i]]<-x[indexes[i]]
    }
  for(i in 11:length(indexes)){
    xHP<-hpfilter(x[indexes[1:(i-1)]])
    result[indexes[i]]<-predHP(xHP)
    }
  return(result)  
  }

Now load the three different datasets. Make sure to save them in the current working directory.

anual<-read.csv("anual.csv")
quarterly<-read.csv("quarterly.csv")
forecasts<-read.csv("forecasts.csv")

Figure 1-a, Annual GDP growth, actual and average. Source: IMF.

anual$GDP_g[2:nrow(anual)] <- 100*(anual$GDP[2:nrow(anual)] - 
    anual$GDP[-nrow(anual)]) / anual$GDP[-nrow(anual)]

plot(anual$Years[!is.na(anual$GDP_g)], anual$GDP_g[!is.na(anual$GDP_g)], type="l", 
     ylab="Real GDP growth rate (%)", xlab="",lwd=2,cex.axis=1.2,cex.lab=1.2)

lines(c(min(anual$Years[!is.na(anual$GDP_g)]), max(anual$Years[!is.na(anual$GDP_g)])), 
      c(0,0), lty=2,lwd=2)

legend(x=1982, y=0, legend=c("Actual", "Average"), lty=c(1,2), bty="n",lwd=2,cex=1.2)

Figure 1-b, Balance of Payment annual surplus. Source: Colombian Central Bank.

plot(anual$Years[!is.na(anual$BOP_SURP)], anual$BOP_SURP[!is.na(anual$BOP_SURP)], type="l", ylab="Balance of Payment Surplus (millions USD)", xlab="",lwd=2,cex.axis=1.2,cex.lab=1.2)

lines(c(min(anual$Years[!is.na(anual$BOP_SURP)]), max(anual$Years[!is.na(anual$BOP_SURP)])), c(0,0), lty=2,lwd=2)

Figure 1-c (not used), Quarterly growth rate. Source: Colombian Central Bank.

plot(quarterly$Year[!is.na(quarterly$MIN_g)], quarterly$GDP_g[!is.na(quarterly$MIN_g)], type="l", ylab="Growth rates (%)", xlab="",ylim=range(quarterly[,c("MIN_g","MAN_g","GDP_g")],na.rm=T),lwd=2)

lines(quarterly$Year[!is.na(quarterly$MIN_g)], quarterly$MAN_g[!is.na(quarterly$MIN_g)], lty=2,lwd=2)

lines(quarterly$Year[!is.na(quarterly$MIN_g)], quarterly$MIN_g[!is.na(quarterly$MIN_g)], lty=3,lwd=2)

legend(x=2007, y=-2, legend=c("GDP", "Mining", "Manufacture"), lty=c(1,2,3),lwd=2, bty="n")

Chow test for structural break in mining sector to gdp growth rate differential

#Determining the index of the structural break
brkYear<-2007.5
brk<-which(quarterly$Year[!is.na(quarterly$MIN_g)]==brkYear)
#Generating the result structure
av<-list()
cTest<-list()
#Generating the growth rate differentials
quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)]<-quarterly$MIN_g[!is.na(quarterly$MIN_g)]-quarterly$GDP_g[!is.na(quarterly$MIN_g)]
quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)]<-quarterly$MAN_g[!is.na(quarterly$MIN_g)]-quarterly$GDP_g[!is.na(quarterly$MIN_g)]
#1. MINING SECTOR
#OLS to compute average growth rate differential
av$MIN_ALL<-lm(quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)] ~ 1)
av$MIN_1<-lm(quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)&quarterly$Year<=brkYear] ~ 1)
av$MIN_2<-lm(quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)&quarterly$Year>brkYear] ~ 1)
#Chow Test fro structural break
cTest$MIN<-sctest(quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)] ~ 1, type = "Chow", point = brk)
#1. MANUFACTURE SECTOR
#OLS to compute average growth rate differential
av$MAN_ALL<-lm(quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)] ~ 1)
av$MAN_1<-lm(quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)&quarterly$Year<=brkYear] ~ 1)
av$MAN_2<-lm(quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)&quarterly$Year>brkYear] ~ 1)
#Chow Test fro structural break
cTest$MAN<-sctest(quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)] ~ 1, type = "Chow", point = brk)

Printing the tables:

##           Full Sample     2001Q1-2007Q3    2007Q4-2014Q1  
## Constant  "0.02 (0.448)"  "-1.066 (0.754)" "1.148 (0.369)"
## Chow Test "6.789 (0.012)" ""               ""
##           Full Sample      2001Q1-2007Q3  2007Q4-2014Q1   
## Constant  "-0.421 (0.216)" "0.13 (0.292)" "-0.993 (0.282)"
## Chow Test "7.616 (0.008)"  ""             ""

Figure 2, Real sectorial shares, source Colombian Central Bank.

plot(anual$Year[!is.na(anual$MIN_GDP_SHARE)], anual$MAN_GDP_SHARE[!is.na(anual$MIN_GDP_SHARE)], type="l", ylab="Real Sectorial Share (% of GDP)", xlab="",ylim=range(anual[,c("MIN_GDP_SHARE","MAN_GDP_SHARE")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)

lines(anual$Year[!is.na(anual$MIN_GDP_SHARE)], anual$MIN_GDP_SHARE[!is.na(anual$MIN_GDP_SHARE)], lty=2,lwd=2)

legend(x=2000, y=12, legend=c("Manufacture","Mining"), lty=c(1,2),lwd=2, bty="n",cex=1.2)