#========================================================# # Quantitative ALM, Financial Econometrics & Derivatives # ML/DL using R, Python, Tensorflow by Sang-Heon Lee # # https://kiandlee.blogspot.com #——————————————————–# # Vector Autoregressive Model #========================================================# graphics.off() # clear all graphs rm(list = ls()) # remove all files from your workspace library(urca) # ca.jo, denmark library(vars) # vec2var #======================================================== # Data #======================================================== # forecasting horizon nhor – 12 #——————————————– # quarterly data related with money demand #——————————————– # LRM : logarithm of real money M2 (LRM) # LRY : logarithm of real income (LRY) # LPY : logarithm of price deflator (LPY) # IBO : bond rate (IBO) # IDE : bank deposit rate (IDE) # the period 1974:Q1 – 1987:Q3 #——————————————– # selected variables data(denmark) df.lev – denmark[,c(“LRM”,“LRY”,“IBO”,“IDE”)] m.lev – as.matrix(df.lev) nr_lev – nrow(df.lev) # quarterly centered dummy variables dum_season – data.frame(yyyymm = denmark$ENTRY) substr.q – as.numeric(substring(denmark$ENTRY, 6,7)) dum_season$Q2 – (substr.q==2)–1/4 dum_season$Q3 – (substr.q==3)–1/4 dum_season$Q4 – (substr.q==4)–1/4 dum_season – dum_season[,–1] # Draw Graph str.main – c( “LRM=ln(real money M2)”, “LRY=ln(real income)”, “IBO=bond rate”, “IDE=bank deposit rate”) x11(width=12, height = 6); par(mfrow=c(2,2), mar=c(5,3,3,3)) for(i in 1:4) { matplot(m.lev[,i], axes=FALSE, type=c(“l”), col = c(“blue”), main = str.main[i]) axis(2) # show y axis # show x axis and replace it with # an user defined sting vector axis(1, at=seq_along(1:nrow(df.lev)), … Read more