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")
#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)
Figure 3, Quarterly growth rate differentials. Source: Colombian Central Bank and authorsโ computations.
plot(quarterly$Year[!is.na(quarterly$MIN_g)], quarterly$MIN_DIFF[!is.na(quarterly$MIN_g)], type="l", ylab="Growth rates (%)", xlab="",ylim=range(quarterly[,c("MIN_DIFF","MAN_DIFF")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(quarterly$Year[!is.na(quarterly$MIN_g)], quarterly$MAN_DIFF[!is.na(quarterly$MIN_g)], lty=2,lwd=2)
lines(c(min(quarterly$Year[!is.na(quarterly$MIN_g)]),max(quarterly$Year[!is.na(quarterly$MIN_g)])),c(0,0),lty=1,lwd=1)
legend(x=2008, y=-4, legend=c("Mining", "Manufacture"), lty=c(1,2),lwd=c(2,2), bty="n",cex=1.2)
Figure 4, Real and nominal exchange rates, source UNCTAD.
plot(anual$Year[!is.na(anual$REAL_EFFECTIVE_ER)], anual$REAL_EFFECTIVE_ER[!is.na(anual$REAL_EFFECTIVE_ER)], type="l", ylab="Exchange rates (2000=100)", xlab="",ylim=range(anual[,c("REAL_EFFECTIVE_ER","REAL_EFFECTIVE_ER")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(anual$Year[!is.na(anual$REAL_EFFECTIVE_ER)], anual$NOMINAL_EFFECTIVE_ER[!is.na(anual$REAL_EFFECTIVE_ER)], lty=2,lwd=2)
legend(x=1995, y=200, legend=c("Real", "Nominal"), lty=c(1,2),lwd=2, bty="n",cex=1.2)
Figure 5, Quarterly FDI sectorial share. Source: Colombian Central Bank.
plot(quarterly$Year[!is.na(quarterly$FDI)], quarterly$FDI[!is.na(quarterly$FDI)], type="l", ylab="Foreign Direct Investment (million USD)", xlab="",ylim=range(quarterly[,c("FDI","FDI_MIN_P","FDI_O")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(quarterly$Year[!is.na(quarterly$FDI)], quarterly$FDI_MIN_P[!is.na(quarterly$FDI)], lty=2,lwd=2)
lines(quarterly$Year[!is.na(quarterly$FDI)], quarterly$FDI_O[!is.na(quarterly$FDI)], lty=3,lwd=2)
legend(x=1996, y=6000, legend=c("Total", "Mining and Petrol", "Others"), lty=c(1,2,3),lwd=2, bty="n",cex=1.2)
Chow test for structural break in mining sector to gdp growth rate differential
#Determining the index of the structural break
breakYear<-2001.5
brk<-which(quarterly$Year[!is.na(quarterly$FDI)]==breakYear)
#Generating the growth rate differentials
quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)]<-quarterly$FDI_MIN_P[!is.na(quarterly$FDI)]/quarterly$FDI[!is.na(quarterly$FDI)]
quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)]<-quarterly$FDI_O[!is.na(quarterly$FDI)]/quarterly$FDI[!is.na(quarterly$FDI)]
#1. MINING SECTOR
#OLS to compute average growth rate differential
av$FDI_MIN_P_ALL<-lm(quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)] ~ 1)
av$FDI_MIN_P_1<-lm(quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)&quarterly$Year<=breakYear] ~ 1)
av$FDI_MIN_P_2<-lm(quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)&quarterly$Year>breakYear] ~ 1)
#Chow Test fro structural break
cTest$FDI_MIN_P<-sctest(quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)] ~ 1, type = "Chow", point = brk)
#1. MANUFACTURE SECTOR
#OLS to compute average growth rate differential
av$FDI_O_ALL<-lm(quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)] ~ 1)
av$FDI_O_1<-lm(quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)&quarterly$Year<=breakYear] ~ 1)
av$FDI_O_2<-lm(quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)&quarterly$Year>breakYear] ~ 1)
#Chow Test fro structural break
cTest$FDI_O<-sctest(quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)] ~ 1, type = "Chow", point = brk)
Printing the tables:
## Full Sample 2001Q1-2007Q3 2007Q4-2014Q1
## Constant "0.421 (0.037)" "0.118 (0.061)" "0.561 (0.031)"
## Chow Test "52.076 (0)" "" ""
## Full Sample 2001Q1-2007Q3 2007Q4-2014Q1
## Constant "0.579 (0.037)" "0.882 (0.061)" "0.439 (0.031)"
## Chow Test "52.076 (0)" "" ""
Figure 5-b (not used), Quarterly FDI shares. Source: Colombian Central Bank and authorsโ computations.
plot(quarterly$Year[!is.na(quarterly$FDI)], quarterly$FDI_MIN_P_SHARE[!is.na(quarterly$FDI)], type="l", ylab="FDI Share", xlab="",ylim=range(quarterly[,c("FDI_MIN_P_SHARE","FDI_O_SHARE")],na.rm=T),lwd=1,cex.axis=1.2,cex.lab=1.2)
lines(quarterly$Year[!is.na(quarterly$FDI)], quarterly$FDI_O_SHARE[!is.na(quarterly$FDI)], lty=2,lwd=1)
lines(c(quarterly$Year[!is.na(quarterly$FDI)][1],quarterly$Year[!is.na(quarterly$FDI)][brk-1],quarterly$Year[!is.na(quarterly$FDI)][brk],max(quarterly$Year[!is.na(quarterly$FDI)])),c(av$FDI_MIN_P_1$coef[1],av$FDI_MIN_P_1$coef[1],av$FDI_MIN_P_2$coef[1],av$FDI_MIN_P_2$coef[1]),lwd=2)
lines(c(quarterly$Year[!is.na(quarterly$FDI)][1],quarterly$Year[!is.na(quarterly$FDI)][brk-1],quarterly$Year[!is.na(quarterly$FDI)][brk],max(quarterly$Year[!is.na(quarterly$FDI)])),c(av$FDI_O_1$coef[1],av$FDI_O_1$coef[1],av$FDI_O_2$coef[1],av$FDI_O_2$coef[1]),lwd=2,lty=2)
legend(x=2001, y=1.8, legend=c("Mining & Petrol", "Other","Mining & Petrol (average)", "Other (average)"), lty=c(1,2,1,2),lwd=c(1,1,2,2), bty="n",cex=1.2)
Figure 6, Current account, and trade balances, source: UNCTAD.
plot(anual$Year[!is.na(anual$TB_GDP)], anual$TB_GDP[!is.na(anual$TB_GDP)], type="l", ylab="% of GDP", xlab="",ylim=range(anual[,c("TB_GDP","CA_GDP.1","MAN_TB_GDP")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(anual$Year[!is.na(anual$CA_GDP.1)], anual$CA_GDP.1[!is.na(anual$CA_GDP.1)], lty=2,lwd=2)
lines(anual$Year[!is.na(anual$MAN_TB_GDP)], anual$MAN_TB_GDP[!is.na(anual$MAN_TB_GDP)], lty=3,lwd=2)
lines(c(min(anual$Years[!is.na(anual$TB_GDP)]), max(anual$Years[!is.na(anual$TB_GDP)])), c(0,0), lty=1,lwd=1)
legend(x=1980, y=-6, legend=c("Trade Balance", "Current Account", "Manufacture Trade Balance"), lty=c(1,2,3),lwd=2, bty="n",cex=1.2)
Figure 7, Deficits in current account, trade balances and net factor income, source: Colombian Central Bank.
plot(anual$Year[!is.na(anual$TB_GDP_INDEX)], anual$TB_GDP_INDEX[!is.na(anual$TB_GDP_INDEX)], type="l", ylab="Deficit, index (1995=100)", xlab="",ylim=range(anual[,c("TB_GDP_INDEX","CA_GDP_INDEX","MAN_TB_GDP_INDEX","NFP_GDP_INDEX")],na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(anual$Year[!is.na(anual$CA_GDP_INDEX)], anual$CA_GDP_INDEX[!is.na(anual$CA_GDP_INDEX)], lty=2,lwd=2)
lines(anual$Year[!is.na(anual$MAN_TB_GDP_INDEX)], anual$MAN_TB_GDP_INDEX[!is.na(anual$MAN_TB_GDP_INDEX)], lty=3,lwd=2)
lines(anual$Year[!is.na(anual$NFP_GDP_INDEX)], anual$NFP_GDP_INDEX[!is.na(anual$NFP_GDP_INDEX)], lty=4,lwd=2)
legend(x=1995, y=4000, legend=c("Trade Balance", "Current Account", "Manufacture Trade Balance", "Net Factor Income"), lty=c(1,2,3,4),lwd=2, bty="n",cex=1.2)
Exercises on trade balance, current account, net factor income and capital account scenarios.
First, the government predictions for exports and imports, Fig 8-a
forecasts$Y_O_e[forecasts$Years==2013]<-anual$X_G_O[anual$Years==2013]/forecasts$p_O_e[forecasts$Years==2013]
for(i in 2:nrow(forecasts)){
forecasts$Y_O_e[i]<-forecasts$Y_O_e[i-1]*(1+forecasts$Y_O_g_e[i])
}
forecasts$X_O_e<-forecasts$Y_O_e*forecasts$p_O_e
#Building uo the series for imports, based on GDP growth expectations and assuming a constant propensity to import out of GDP
forecasts$M_e[1]<-anual$M[anual$Years==2013]
for(i in 2:nrow(forecasts)){
forecasts$M_e[i]<-forecasts$M_e[i-1]*(1+forecasts$GDP_g[i])
}
plot(anual$Years[!is.na(anual$X_G_O)], anual$X_G_O[!is.na(anual$X_G_O)], type="l", ylab="million USD", xlab="",xlim=range(c(anual$Year[!is.na(anual$X_G_O)],forecasts$Years)), ylim=range(c(anual[,c("X_G_O","M")],forecasts[,c("X_O_e","M_e")]),na.rm=T),lwd=1,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$X_O_e, lty=1,lwd=2)
lines(anual$Year[!is.na(anual$M)], anual$M[!is.na(anual$M)], lty=2,lwd=1)
lines(forecasts$Year, forecasts$M_e, lty=2,lwd=2)
legend(x=1995, y=135000, legend=c("Petrol Exports", "Petrol Exports (Expected)", "Imports", "Imports (Expected"), lty=c(1,1,2,2),lwd=c(1,2,1,2), bty="n",cex=1.2)
Second, the goverment predictions on current account, capital account, and FDI, fig 8-b
#Building up the series for current account, based on price and output growth expectations
anual$FDI_GDP[!is.na(anual$FDI)]<-anual$FDI[!is.na(anual$FDI)]/anual$GDP_USD[!is.na(anual$FDI)]
anual$KA_GDP[!is.na(anual$KA)]<-anual$KA[!is.na(anual$KA)]/anual$GDP_USD[!is.na(anual$KA)]
forecasts$CA_GDP[forecasts$Years==2013]<-anual$CA_GDP[anual$Years==2013]
forecasts$FDI_GDP[forecasts$Years==2013]<-anual$FDI_GDP[anual$Years==2013]
forecasts$KA_GDP[forecasts$Years==2013]<-anual$KA_GDP[anual$Years==2013]
plot(anual$Years[!is.na(anual$CA_GDP)], 100*anual$CA_GDP[!is.na(anual$CA_GDP)], type="l", ylab="% of GDP", xlab="",xlim=range(c(anual$Year[!is.na(anual$CA_GDP)],forecasts$Years)), ylim=100*range(c(anual[,c("CA_GDP","KA_GDP","FDI_GDP")],forecasts[,c("CA_GDP","KA_GDP","FDI_GDP")]),na.rm=T),lwd=1,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, 100*forecasts$CA_GDP, lty=1,lwd=2)
lines(anual$Years[!is.na(anual$KA_GDP)],100* anual$KA_GDP[!is.na(anual$KA_GDP)],lty=2,lwd=1)
lines(forecasts$Year, 100*forecasts$KA_GDP, lty=2,lwd=2)
lines(anual$Years[!is.na(anual$FDI_GDP)], 100*anual$FDI_GDP[!is.na(anual$FDI_GDP)],lty=3,lwd=1)
lines(forecasts$Year, 100*forecasts$FDI_GDP, lty=3,lwd=2)
legend(x=2002, y=1, legend=c("Current Account", "Capital Account", "Foreign Direct Investment"), lty=c(1,2,3),lwd=1, bty="n",cex=1.2)
We know that the current account is equal to the trade balance plus net factor income, however we still have two unknown on that side of the balance of payments, namely non-oil exports and net factor income. We thus have to build a trend for one of these and then compute the other one so that government forecasts all match together.
First, we assume that non-oil exports is the residual, fig9-a. We assume three different trends for net fcator income, a. constant level, b. constant share to GDP and c. HP-filter trend
#Building up the series for NFP, trend 1 constant level
forecasts$NFP_T_1<-anual$NFP[anual$Years==2013]
#Building up the series for NFP, trend 2 constant GDP share
forecasts$GDP_USD[forecasts$Years==2013]<-anual$GDP_USD[anual$Years==2013]
forecasts$NFP_T_2[forecasts$Years==2013]<-anual$NFP[anual$Years==2013]
ratioNFP_GDP<-forecasts$NFP_T_2[forecasts$Years==2013]/forecasts$GDP_USD[forecasts$Years==2013]
for(i in 2:nrow(forecasts)){
forecasts$GDP_USD[i]<-forecasts$GDP_USD[i-1]*(1+forecasts$GDP_g[i])
forecasts$NFP_T_2[i]<-forecasts$GDP_USD[i]*ratioNFP_GDP
}
#Building up the series for NFP, trend 3 HP trends
forecasts$NFP_T_3[forecasts$Years==2013]<-anual$NFP[anual$Years==2013]
tsNFP<-anual$NFP[!is.na(anual$NFP)]
for(i in 2:nrow(forecasts)){
hpNFP<-hpfilter(tsNFP)
forecasts$NFP_T_3[i]<-predHP(hpNFP)
tsNFP<-c(anual$NFP[!is.na(anual$NFP)],forecasts$NFP_T_3[1:i])
}
plot(anual$Years[!is.na(anual$NFP)], anual$NFP[!is.na(anual$NFP)], type="l", ylab="Net Factor Income (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$NFP)],forecasts$Years)), ylim=range(c(anual[,c("NFP")],forecasts[,c("NFP_T_1","NFP_T_2","NFP_T_3")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$NFP_T_1, lty=2,lwd=2)
lines(forecasts$Year, forecasts$NFP_T_2, lty=3,lwd=2)
lines(forecasts$Year, forecasts$NFP_T_3, lty=4,lwd=2)
legend(x=1994, y=-10000, legend=c("Actual", "Constant Value", "Constant Share of GDP", "HP-trend"), lty=c(1,2,3,4),lwd=2, bty="n",cex=1.2)
We can thus compute the residual for non-oil exports and plot the intended growth rates of non oil exports for the various secenari, fig 9-b
#Building up the actual X_NO
anual$X_NO<-anual$TB-anual$X_G_O+anual$M
#Building up the forecasted CA
forecasts$CA<-forecasts$CA_GDP*forecasts$GDP_USD
#Building up the series for X_NO as a residual of the NFP trend 1
forecasts$X_NO_R_1<-forecasts$CA-forecasts$X_O_e-forecasts$NFP_T_1+forecasts$M
#Building up the series for X_NO as a residual of the NFP trend 2
forecasts$X_NO_R_2<-forecasts$CA-forecasts$X_O_e-forecasts$NFP_T_2+forecasts$M
#Building up the series for X_NO as a residual of the NFP trend 3
forecasts$X_NO_R_3<-forecasts$CA-forecasts$X_O_e-forecasts$NFP_T_3+forecasts$M
#Setting the first year of the forecasting series
forecasts$X_NO_R_1[forecasts$Years==2013]<-anual$X_NO[anual$Years==2013]
forecasts$X_NO_R_2[forecasts$Years==2013]<-anual$X_NO[anual$Years==2013]
forecasts$X_NO_R_3[forecasts$Years==2013]<-anual$X_NO[anual$Years==2013]
#Computing the forecasts of GDP in USD
forecasts$GDP_USD[forecasts$Years==2013]<-anual$GDP_USD[anual$Years==2013]
for(i in 2:nrow(forecasts)){
anual$X_NO_GDP[i]<-anual$X_NO_GDP[i-1]*(1+forecasts$GDP_g[i])
}
#Computing Non oil exports as a share of GDP
anual$X_NO_GDP<-anual$X_NO/anual$GDP_USD
forecasts$X_NO_R_1_GDP<-forecasts$X_NO_R_1/forecasts$GDP_USD
forecasts$X_NO_R_2_GDP<-forecasts$X_NO_R_2/forecasts$GDP_USD
forecasts$X_NO_R_3_GDP<-forecasts$X_NO_R_3/forecasts$GDP_USD
plot(anual$Years[!is.na(anual$X_NO_GDP)], anual$X_NO_GDP[!is.na(anual$X_NO_GDP)], type="l", ylab="Share of GDP", xlab="", xlim=range(c(anual$Year[!is.na(anual$X_NO_GDP)],forecasts$Years)), ylim=range(c(anual[,c("X_NO_GDP")],forecasts[,c("X_NO_R_1_GDP","X_NO_R_2_GDP","X_NO_R_3_GDP")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year[!is.na(forecasts$X_NO_R_1_GDP)], forecasts$X_NO_R_1_GDP[!is.na(forecasts$X_NO_R_1_GDP)], lty=2,lwd=2)
lines(forecasts$Year[!is.na(forecasts$X_NO_R_1_GDP)], forecasts$X_NO_R_2_GDP[!is.na(forecasts$X_NO_R_1_GDP)], lty=3,lwd=2)
lines(forecasts$Year[!is.na(forecasts$X_NO_R_1_GDP)], forecasts$X_NO_R_3_GDP[!is.na(forecasts$X_NO_R_1_GDP)], lty=4,lwd=2)
legend(x=2007, y=0.14, legend=c("Actual","NFI Constant Value", "NFI Constant Share", "NFI HP-trend"), lty=c(1,2,3,4),lwd=2, bty="n",cex=1.2)
Same exercise, but now we assume that net factor income is the residual, fig 10-a. We assume three different trends for non oil exports, a. constant share to GDP and b. HP-filter trend
#Building up the series for NFP, trend 1 same growth rate as GDP
forecasts$X_NO_T_1[forecasts$Years==2013]<-anual$X_NO[anual$Years==2013]
for(i in 2:nrow(forecasts)){
forecasts$X_NO_T_1[i]<-forecasts$X_NO_T_1[i-1]*(1+forecasts$GDP_g[i])
}
#Building up the series for NFP, trend 2 HP trends
forecasts$X_NO_T_2[forecasts$Years==2013]<-anual$X_NO[anual$Years==2013]
tsX_NO<-anual$X_NO[!is.na(anual$X_NO)]
for(i in 2:nrow(forecasts)){
hpX_NO<-hpfilter(tsX_NO)
forecasts$X_NO_T_2[i]<-predHP(hpX_NO)
tsX_NO<-c(anual$X_NO[!is.na(anual$X_NO)],forecasts$X_NO_T_2[1:i])
}
plot(anual$Years[!is.na(anual$X_NO)], anual$X_NO[!is.na(anual$X_NO)], type="l", ylab="Non oil exports (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$X_NO)],forecasts$Years)), ylim=range(c(anual[,c("X_NO")],forecasts[,c("X_NO_T_1","X_NO_T_2")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$X_NO_T_1, lty=2,lwd=2)
lines(forecasts$Year, forecasts$X_NO_T_2, lty=3,lwd=2)
legend(x=2010, y=30000, legend=c("Actual", "GDP growth rate", "HP-trend"), lty=c(1,2,3),lwd=2, bty="n",cex=1.2)
We can thus compute the residual for net factor payment, fig 10-b.
#Building up the series for X_NO as a residual of the NFP trend 1
forecasts$NFP_R_1<-forecasts$CA-forecasts$X_O_e-forecasts$X_NO_T_1+forecasts$M
#Building up the series for X_NO as a residual of the NFP trend 2
forecasts$NFP_R_2<-forecasts$CA-forecasts$X_O_e-forecasts$X_NO_T_2+forecasts$M
plot(anual$Years[!is.na(anual$NFP)], anual$NFP[!is.na(anual$NFP)], type="l", ylab="Net Factor Income (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$NFP)],forecasts$Years)), ylim=range(c(anual[,c("NFP")],forecasts[,c("NFP_R_1","NFP_R_2")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$NFP_R_1, lty=2,lwd=2)
lines(forecasts$Year, forecasts$NFP_R_2, lty=3,lwd=2)
legend(x=1995, y=30000, legend=c("Actual", "X_NO Constant Share of GDP", "X_NO HP-trend"), lty=c(1,2,3),lwd=2, bty="n",cex=1.2)
We can now compute two scenarios for the current account, keeping the government forecasts on imports and oil exports but using two trends for net factor income (constant share of GDP and HP-trend) and non-oil exports (growth rate of GDP and HP-trend). Figure 11-a
#Building up the series for CA, growth rate of GDP for X_NO and constant GDP share for NFP
forecasts$CA_T_1<-forecasts$X_O_e+forecasts$X_NO_T_1-forecasts$M+forecasts$NFP_T_2
#Building up the series for CA, HP trends for X_NO and NFP
forecasts$CA_T_2<-forecasts$X_O_e+forecasts$X_NO_T_2-forecasts$M+forecasts$NFP_T_3
plot(anual$Years[!is.na(anual$CA)], anual$CA[!is.na(anual$CA)], type="l", ylab="Current account (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$CA)],forecasts$Years)), ylim=range(c(anual[,c("CA")],forecasts[,c("CA_T_1","CA_T_2")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$CA, lty=2,lwd=2)
lines(forecasts$Year, forecasts$CA_T_1, lty=3,lwd=2)
lines(forecasts$Year, forecasts$CA_T_2, lty=4,lwd=2)
legend(x=1995, y=-40000, legend=c("Actual", "Government forecasts","GDP trends", "HP-trends"), lty=c(1,2,3,4),lwd=2, bty="n",cex=1.2)
We can now compute the capital account necessary to balance the current account, assuming no changes in reserves and compare it with government forecasts and HP-trend, figure 11-b.
#Building the Capital Account government series
forecasts$KA<-forecasts$KA_GDP*forecasts$GDP_USD
#Building up the series for Capital Account, based on CA trend 1
forecasts$KA_T_1<-forecasts$CA_T_1
forecasts$KA_T_1[forecasts$Years==2013]<-forecasts$CA_T_1[forecasts$Years==2013]-anual$CA[anual$Years==2013]+anual$KA[anual$Years==2013]
#Building up the series for Capital Account, based on CA trend 2
forecasts$KA_T_2<-forecasts$CA_T_2
forecasts$KA_T_2[forecasts$Years==2013]<-forecasts$CA_T_2[forecasts$Years==2013]-anual$CA[anual$Years==2013]+anual$KA[anual$Years==2013]
#Building up the series of HP-trended Capital accoutn
forecasts$KA_T_3<-forecasts$KA
tsKA<-anual$KA[!is.na(anual$KA)]
for(i in 2:nrow(forecasts)){
hpKA<-hpfilter(tsKA)
forecasts$KA_T_3[i]<-predHP(hpKA)
tsKA<-c(anual$KA[!is.na(anual$KA)],forecasts$KA_T_3[1:i])
}
plot(anual$Years[!is.na(anual$KA)], -anual$KA[!is.na(anual$KA)], type="l", ylab="Capital account (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$KA)],forecasts$Years)), ylim=range(c(-anual[,c("KA")],-forecasts[,c("KA","KA_T_1","KA_T_2","KA_T_3")]),na.rm=T),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, -forecasts$KA, lty=2,lwd=2)
lines(forecasts$Year, -forecasts$KA_T_3, lty=3,lwd=2)
lines(forecasts$Year, -forecasts$KA_T_1, lty=4,lwd=2)
lines(forecasts$Year, -forecasts$KA_T_2, lty=5,lwd=2)
legend(x=1995, y=70000, legend=c("Actual", "Government forecasts","Capital account HP-trend","Current account GDP trend", "Current account HP-trends"), lty=c(1,2,3,4,5),lwd=2, bty="n",cex=1.2)
If the capital account follows the government predictions, we can compute changes in reserves and plot the resulting reserves stock, assuming the central banks defend the current exchange rate, figure 12.
#Building the Reserve series, according to the 4 scenarios
forecasts$RES[forecasts$Years==2013]<-anual$RES[anual$Years==2013]
forecasts$RES_T_1[forecasts$Years==2013]<-anual$RES[anual$Years==2013]
forecasts$RES_T_2[forecasts$Years==2013]<-anual$RES[anual$Years==2013]
forecasts$RES_T_3[forecasts$Years==2013]<-anual$RES[anual$Years==2013]
forecasts$RES_T_4[forecasts$Years==2013]<-anual$RES[anual$Years==2013]
for(i in 2:nrow(forecasts)){
forecasts$RES[i]=forecasts$RES[i-1]+forecasts$CA[i]-forecasts$KA[i]
forecasts$RES_T_1[i]=forecasts$RES_T_1[i-1]+forecasts$CA_T_1[i]-forecasts$KA[i]
forecasts$RES_T_2[i]=forecasts$RES_T_2[i-1]+forecasts$CA_T_2[i]-forecasts$KA[i]
forecasts$RES_T_3[i]=forecasts$RES_T_3[i-1]+forecasts$CA_T_1[i]-forecasts$KA_T_3[i]
forecasts$RES_T_4[i]=forecasts$RES_T_4[i-1]+forecasts$CA_T_2[i]-forecasts$KA_T_3[i]
}
plot(anual$Years[!is.na(anual$RES)], anual$RES[!is.na(anual$RES)], type="l", ylab="Reserves (million USD)", xlab="",xlim=range(c(anual$Year[!is.na(anual$RES)],forecasts$Years)), ylim=c(0,max(range(c(anual[,c("RES")],forecasts[,c("RES","RES_T_1","RES_T_2","RES_T_3","RES_T_4")]),na.rm=T))),lwd=2,cex.axis=1.2,cex.lab=1.2)
lines(forecasts$Year, forecasts$RES, lty=2,lwd=2)
lines(forecasts$Year, forecasts$RES_T_1, lty=3,lwd=2)
lines(forecasts$Year, forecasts$RES_T_2, lty=4,lwd=2)
lines(forecasts$Year, forecasts$RES_T_3, lty=5,lwd=2)
lines(forecasts$Year, forecasts$RES_T_4, lty=6,lwd=2)
legend(x=1995, y=85000, legend=c("Actual", "Government forecasts","Scenario 1", "Scenario 2","Scenario 3", "Scenario 4"), lty=c(1,2,3,4,5,6),lwd=2, bty="n",cex=1.2)
