Discussion Week 6

VAR Model for Colombia’s GDP and Procolombia’s exports.

For this week i will use colombia’s GDP and Procolombia’s Exports between 2009 and 2022.

PIB_Export <- read_excel("~/Desktop/PIB_Export.xlsx")

t=seq(2009.1,2022.2, length.out=length(PIB_Export$DATE))


export<-ts(PIB_Export$EXPORT1,frequency=4,start=c(2005,1)) 

plot(export)

Following Colombia’s department of statistics, this series controls for stationary effects. We can see clearly the positive trend.

GDP<-ts(PIB_Export$GDP,frequency=4,start=c(2005,1)) 

plot(GDP)

acf(GDP) 

plot(diff(GDP))

acf(diff(GDP))

Here we don’t have any significant lag. First difference works in this case.

PIB_Export <- na.omit(PIB_Export)
vardata = subset(PIB_Export, select = c(GDP,EXPORT1) )

VARselect(vardata, lag.max = 8, type = "const")$selection
## AIC(n)  HQ(n)  SC(n) FPE(n) 
##      4      4      4      4
VAR1 <- VAR(vardata, p = 4, type = "const")
VAR1
## 
## VAR Estimation Results:
## ======================= 
## 
## Estimated coefficients for equation GDP: 
## ======================================== 
## Call:
## GDP = GDP.l1 + EXPORT1.l1 + GDP.l2 + EXPORT1.l2 + GDP.l3 + EXPORT1.l3 + GDP.l4 + EXPORT1.l4 + const 
## 
##        GDP.l1    EXPORT1.l1        GDP.l2    EXPORT1.l2        GDP.l3 
##  9.184849e-01 -3.501472e-06  6.522598e-02  7.148131e-06 -1.388338e-01 
##    EXPORT1.l3        GDP.l4    EXPORT1.l4         const 
##  8.397840e-06  6.788083e-02  5.709185e-07  1.336762e+04 
## 
## 
## Estimated coefficients for equation EXPORT1: 
## ============================================ 
## Call:
## EXPORT1 = GDP.l1 + EXPORT1.l1 + GDP.l2 + EXPORT1.l2 + GDP.l3 + EXPORT1.l3 + GDP.l4 + EXPORT1.l4 + const 
## 
##        GDP.l1    EXPORT1.l1        GDP.l2    EXPORT1.l2        GDP.l3 
##  4.562427e+03  5.368368e-03 -3.731246e+03 -2.048899e-01  1.246175e+04 
##    EXPORT1.l3        GDP.l4    EXPORT1.l4         const 
##  9.741074e-02 -9.743765e+03  8.301648e-01 -4.652709e+08
tsdisplay(residuals(VAR1))

In both graphs we see a significant lag in 4.

predict1 <- predict(VAR1, n.ahead = 4)

plot(predict1)