Packages

library(zoo)

library(quantmod)

library(dynlm)

library(urca)

library(stargazer)

library(ARDL)

library(xts)

library(strucchange)

library(tibble)

library(lmtest)

library(ggplot2)

naming columns

colnames(Book1) <- c(“year”,“LNGDP”,“LNGFCE”,“LNGFC”,“LNFDI”)

Calculation within the data

Book1\(LNGDP <- log(Book1\)LNGDP)

Book1\(LNFDI <- log(Book1\)LNFDI)

Book1\(LNGFCE <- log(Book1\)LNGFCE)

Book1\(LNGFC <- log(Book1\)LNGFC)

Define Yearly time series beginnig in 1985

tsdata <- ts(Book1,start = 1985)

class(Book1)

zoodata

zoodata <- zoo(Book1, order.by = Book1$year)

ADF Unit Root test for LNGDP

adf.none.level.LNGDP <- ur.df(zoodata$LNGDP, type = c(“none”), selectlags = “AIC”)

summary(adf.none.level.LNGDP)

adf.drift.level.LNGDP <- ur.df(zoodata$LNGDP, type = c(“drift”), selectlags = “AIC”)

summary(adf.drift.level.LNGDP)

adf.trend.level.LNGDP <- ur.df(zoodata$LNGDP, type = “trend”, selectlags = “AIC”)

summary(adf.trend.level.LNGDP)

The computed |τ | does not exceed the absolute critcal |τ | we accept H1
LNGDP is not stationary with trend or without

ADF Unit Root test for LNGDP after first difference

DLNGDP <- diff(zoodata$LNGDP)

adf.drift.after.diff.LNGDP <- ur.df(DLNGDP, type = “drift”, selectlags = “AIC”)

summary(adf.drift.after.diff.LNGDP)

adf.trend.after.diff.LNGDP <- ur.df(DLNGDP, type = “trend”, selectlags = “AIC”)

summary(adf.trend.after.diff.LNGDP)

LNGDP is stationary in trend or drift at 1% and 5% of significanse

ADF Unit Root test for LNFDI

adf.none.level.LNFDI <- ur.df(zoodata$LNFDI, type = c(“none”), selectlags = “AIC”)

summary(adf.none.level.LNFDI)

adf.drift.level.LNFDI <- ur.df(zoodata$LNFDI, type = c(“drift”), selectlags = “AIC”)

summary(adf.drift.level.LNFDI)

adf.trend.level.LNFDI <- ur.df(zoodata$LNFDI, type = “trend”, selectlags = “AIC”)

summary(adf.trend.level.LNFDI) ###### The computed |τ | does not exceed the absolute critcal |τ | we accept H1

LNFDI is not stationary with trend or without.

ADF Unit Root test for LNFDI after first difference

DLNFDI <- diff(zoodata$LNFDI)

adf.drift.after.diff.LNFDI <- ur.df(DLNFDI, type = “drift”, selectlags = “AIC”) summary(adf.drift.after.diff.LNFDI)

adf.trend.after.diff.LNFDI <- ur.df(DLNFDI, type = “trend”, selectlags = “AIC”)

summary(adf.trend.after.diff.LNFDI)

LNFDI is stationary with trend or without at 5% and 10% of significanse

ADF Unit Root test for LNGFC

adf.none.level.LNGFC <- ur.df(zoodata$LNGFC, type = c(“none”), selectlags = “AIC”) summary(adf.none.level.LNGFC)

adf.drift.level.LNGFC <- ur.df(zoodata$LNGFC, type = c(“drift”), selectlags = “AIC”) summary(adf.drift.level.LNGFC)

adf.trend.level.LNGFC <- ur.df(zoodata$LNGFC, type = “trend”, selectlags = “AIC”)

summary(adf.trend.level.LNGFC)

LNGFC is stationary with trend at 1%, 5%, and 10% of significanse

ADF Unit Root test for LNGFC after first difference

DLNGFC <- diff(zoodata$LNGFC)

adf.drift.after.diff.LNGFC <- ur.df(DLNGFC, type = “drift”, selectlags = “AIC”) summary(adf.drift.after.diff.LNGFC)

adf.trend.after.diff.LNGFC <- ur.df(DLNGFC, type = “trend”, selectlags = “AIC”)

summary(adf.trend.after.diff.LNGFC)

ADF Unit Root test for LNGFCE

adf.none.level.LNGFCE <- ur.df(zoodata$LNGFCE, type = c(“none”), selectlags = “AIC”) summary(adf.none.level.LNGFCE)

adf.drift.level.LNGFCE <- ur.df(zoodata$LNGFCE, type = c(“drift”), selectlags = “AIC”) summary(adf.drift.level.LNGFCE)

adf.trend.level.LNGFCE <- ur.df(zoodata$LNGFCE, type = “trend”, selectlags = “AIC”)

summary(adf.trend.level.LNGFCE)

ADF Unit Root test for LNGFCE after first difference

DLNGFCE <- diff(zoodata$LNGFCE)

adf.drift.after.diff.LNGFCE <- ur.df(DLNGFCE, type = “drift”, selectlags = “AIC”)

summary(adf.drift.after.diff.LNGFCE)

adf.trend.after.diff.LNGFCE <- ur.df(DLNGFCE, type = “trend”, selectlags = “AIC”)

summary(adf.trend.after.diff.LNGFCE)

ARDL

models <- auto_ardl(LNGDP ~ LNGFC +LNGFCE +LNFDI, data = tsdata, max_order = 2)

The top 20 models according to the AIC

models$top_orders

The best model was found to be the ARDL (1,1,1,0)

ardl_1110 <- models$best_model

ardl_1110$order

summary(ardl_1110)

###Bounds Test for cointegration

bounds <- bounds_f_test(ardl_1110, case = 2)

print(bounds)

Test for autocorrelation and heteroscedasticity

bptest(ardl_1110)

bgtest(ardl_1110, order = 3)

bgtest(ardl_1110, order = 3, type = “F”)

Durbin-watson for first order Auto correlation test

dwtest(ardl_1110)

(UECM) Unrestricted error correction model

uecm_1110 <- uecm(ardl_1110)

summary(uecm_1110)

dwtest(uecm_1110)

the bonds_f_test(uecm_1110 ,case=2)

bounds <- bounds_f_test(uecm_1110, case = 2)

bounds$Fstat

bounds$tab

short run and long run multipliers

multipliers(ardl_1110, type = “sr”)

multipliers(ardl_1110)

CUSUM test for stability

cusum_test <- efp(ardl_1110, data = tsdata)

plot(cusum_test, main = “CUSUM Test”, ylab = “CUSUM”, xlab = “Time”, col = “blue”, lwd = 2) abline(h = 0.948, col = “red”, lty = 2, lwd = 2)
abline(h = -0.948, col = “red”, lty = 2, lwd = 2)

Visualization