Impulse response function (IRF) for VECM

152 Views Asked by At

I need help with irf plots. I am working with R and hope You can help me here. My VECM model consist of three endogenous variables and two exogenous variables. When I transform VECM to VAR using vec2var function and try to plot impulse response functions it shows only endogenous variables, because vec2var takes cointegration test results and cointegration was tested between three I(1) variables. So is it possible to plot IRF with those exogenous variables or not really? I tried to use VARXirf, but it doesn't work for me.

My data:

structure(list(date = structure(c(1546214400, 1548892800, 1551312000, 
1553817600, 1556582400, 1559260800, 1561680000, 1564531200, 1567123200, 
1569801600, 1572480000, 1574985600, 1577750400, 1580428800, 1582848000, 
1585612800, 1588204800, 1590710400, 1593475200, 1596153600, 1598832000, 
1601424000, 1604016000, 1606694400, 1609372800, 1611878400, 1614297600, 
1617148800, 1619740800, 1622419200, 1625011200, 1627603200, 1630368000, 
1632960000, 1635465600, 1638230400, 1640908800, 1643587200, 1646006400, 
1648684800, 1651190400, 1653955200, 1656547200, 1659052800, 1661904000, 
1664496000, 1667174400, 1669766400, 1672358400), class = c("POSIXct", 
"POSIXt"), tzone = "UTC"), avi96 = c(0, 3.10999999999999, 3.18000000000001, 
2.06999999999999, 3.79, -6.25, 3.53000000000001, 3.70999999999999, 
-1.79, 2.01, 0.780000000000003, 4.45, 0.980000000000003, 1.77, 
-8.88, -12.83, 10.94, 1.73000000000001, 0.469999999999993, 2.59, 
6.03, -2.89999999999999, -2.23, 9.32999999999999, 1.85, 1.06999999999999, 
1.59, 5.54000000000001, 3.78000000000001, 0.519999999999987, 
3.46, 2.11000000000001, 3.08999999999999, -3.04, 6.03, 1.05, 
3.46, -7.80999999999998, -3.4, 5.96999999999999, -3.26, -5.33999999999999, 
-8.18000000000001, 11.68, -2.12000000000001, -9.31999999999999, 
5.66, 0.120000000000009, -6.13000000000001), avi89 = c(0, 2.47999999999999, 
2.34000000000001, 1.72999999999999, 3.87000000000002, -6.13000000000001, 
3.54000000000001, 3.68999999999999, -1.69999999999999, 1.99, 
0.829999999999997, 4.30999999999999, 1.05, 1.77, -8.99000000000001, 
-12.68, 10.74, 1.88999999999999, 0.51000000000001, 2.75999999999998, 
6.01, -2.87999999999999, -2.12000000000001, 8.94000000000002, 
1.90999999999999, 1.18, 1.27999999999999, 5.68000000000002, 3.54999999999999, 
0.0399999999999956, 3.75000000000001, 2, 2.99, -3.22, 6.21, 1.10999999999999, 
3.46, -7.88, -3.37000000000001, 5.70000000000002, -3.03, -5.41, 
-7.78000000000001, 10.74, -1.77, -9.41000000000001, 6.19000000000001, 
0.209999999999999, -5.71999999999999), avi82 = c(0, 2.64, 2.30000000000001, 
1.79999999999998, 3.89000000000002, -6.16000000000001, 3.6, 3.65, 
-1.63, 1.96000000000001, 0.839999999999996, 4.24, 1.12000000000001, 
1.70999999999999, -9.00000000000001, -12.59, 10.87, 1.81, 0.570000000000004, 
2.91999999999999, 6.04, -2.89999999999999, -2.02, 8.75999999999999, 
2.03, 1.03, 1.21, 5.73000000000001, 3.63, -0.140000000000007, 
3.84, 1.99, 2.88999999999999, -3.22, 6.08, 1.12000000000001, 
3.48999999999999, -8.02999999999998, -3.19, 5.48999999999999, 
-2.92000000000001, -5.52999999999999, -7.74999999999999, 10.84, 
-1.87999999999999, -9.31, 6.21, 0.209999999999999, -5.77000000000001
), avi75 = c(0, 2.4, 2.32999999999999, 1.83000000000002, 3.86, 
-6.20000000000001, 3.57000000000001, 3.63, -1.61, 1.96999999999998, 
0.850000000000017, 4.30999999999999, 1.09999999999999, 1.69000000000001, 
-9.05, -12.73, 10.83, 1.85999999999999, 0.580000000000003, 3.01, 
5.96999999999999, -2.94999999999999, -2.10000000000001, 8.7, 
2.06000000000002, 0.969999999999982, 1.24, 5.66000000000002, 
3.68999999999999, -0.239999999999996, 3.8, 1.84, 2.77999999999998, 
-3.23, 5.98000000000001, 1.02, 3.46, -7.9, -3.4, 5.38000000000001, 
-3.01, -5.61, -7.65, 10.72, -1.97999999999998, -9.34000000000001, 
6.04, 0.330000000000008, -5.45), log_gdp_world = c(9.51402553826992, 
9.51695983285129, 9.51960278314398, 9.52252078178507, 9.52769416651787, 
9.5330120282788, 9.53813155944057, 9.54862172776332, 9.55900299386891, 
9.56894779939131, 9.56614165901463, 9.56341852114707, 9.56059679989229, 
9.55914808220437, 9.55779092749273, 9.55633813622136, 9.52670058541251, 
9.49512341506964, 9.46358512351927, 9.46820769177734, 9.47280899018176, 
9.4772417914128, 9.47734257526361, 9.47744009835223, 9.4775408622199, 
9.48109644409051, 9.48429710719872, 9.48782878988212, 9.49166064704964, 
9.49560486751224, 9.49940709976824, 9.50948847790104, 9.51946923539974, 
9.52903410235035, 9.54422639425026, 9.5587120696073, 9.57346337036549, 
9.57945441948591, 9.5848350110093, 9.59075851820953, 9.60767235378505, 
9.62485454389854, 9.64120601544112, 9.66212047614465, 9.68260646807701, 
9.70203987440834, 9.69431920882583, 9.68679040927181, 9.67895063912544
), log_cci_world = c(4.61446609380263, 4.61277821772403, 4.61331075141384, 
4.61515114030563, 4.61654561269239, 4.61741790909265, 4.61667387658147, 
4.61475796175261, 4.61210440764257, 4.61189685561528, 4.61356703849811, 
4.61600998526375, 4.61799585862336, 4.61784626499577, 4.61330787560473, 
4.60277023301779, 4.59132809646505, 4.58666841950006, 4.58717164824433, 
4.58837654934904, 4.59059751202271, 4.59328883112521, 4.59424110855891, 
4.59374163386604, 4.59412528763382, 4.59472152015799, 4.59693515378804, 
4.60123153909827, 4.60423308989254, 4.60479244197868, 4.60395680791926, 
4.60038748009664, 4.59543994917727, 4.5925448139507, 4.59058755330096, 
4.58886818984625, 4.58736479091539, 4.58432260590939, 4.58025039378034, 
4.576616768349, 4.57405218172779, 4.56985995266299, 4.56579695147534, 
4.56508357652314, 4.5669702578309, 4.56839897041546, 4.56926511182164, 
4.56999071374327, 4.57211892815316), log_interest_rate_world = c(0.73750617161218, 
0.73750617161218, 0.73750617161218, 0.73750617161218, 0.73750617161218, 
0.73750617161218, 0.73750617161218, 0.637327088752386, 0.637327088752386, 
0.525983316877571, 0.400670513983926, 0.400670513983926, 0.400670513983926, 
0.400670513983926, 0.400670513983926, -0.466604956417612, -1.57645902152713, 
-1.57645902152713, -1.57645902152713, -1.57645902152713, -1.57645902152713, 
-1.57645902152713, -1.57645902152713, -1.57645902152713, -1.57645902152713, 
-1.57645902152713, -1.57645902152713, -1.57645902152713, -1.57645902152713, 
-1.57645902152713, -1.57645902152713, -1.57645902152713, -1.57645902152713, 
-1.57645902152713, -1.57645902152713, -1.57645902152713, -1.54102355917488, 
-1.54102355917488, -1.48461963274523, -0.802998682642699, -0.760725879123157, 
-0.129713535011207, 0.410788934029564, 0.772710018402493, 0.784120997603494, 
1.05563666438959, 1.07319628045347, 1.26972761362108, 1.3922059271877
), log_inflation_world = c(0.579671239393745, 0.394810660724412, 
0.348847200537183, 0.568187221339436, 0.639716724077389, 0.539826558640262, 
0.440461019721857, 0.530131610274996, 0.45553099850797, 0.448249068858724, 
0.489277417561056, 0.648158398620189, 0.743961755455804, 0.828137063583557, 
0.737640738475294, 0.310093183529362, -1.23428296340388, -2.17890570663116, 
-0.596260922732999, -0.0985710592789802, 0.0704923328990548, 
0.148642319410966, -0.0104885765020048, -0.0475734369214894, 
0.0826544982337352, 0.152001327577498, 0.341275620749666, 0.792971296608749, 
1.25994196106498, 1.44235441243902, 1.52081808068586, 1.5208616326286, 
1.52470721099492, 1.5552305224244, 1.69558119096896, 1.79466263665391, 
1.82618166169172, 1.88825194036522, 1.95204603390144, 2.03593698836315, 
2.04250906432006, 2.08015494482607, 2.13448687394192, 2.08155682925827, 
2.05985920078705, 2.048801029161, 2.01298011001907, 1.94458956552755, 
1.86949272164845), trade.balance.world = c(-0.142313796014068, 
-0.104120362016413, -0.0812523582063306, -0.0615781276670574, 
-0.0283369336459555, -0.00806386336459555, -0.0330441372098476, 
-0.0440851797186401, -0.0415415234701055, -0.0234747554279015, 
-0.0349449813130129, -0.0238873536928488, -0.00520093463071512, 
-0.072785495978898, -0.0752476913599062, -0.110424157033998, 
-0.146270990433763, -0.0567695920515827, -0.0680010167057444, 
-0.0757696093786635, -0.0842919657678781, -0.10249344073857, 
-0.0955763532942556, -0.0848047153575616, -0.0404103492379836, 
0.0191720513950762, 0.0179966138335287, -0.0511700359906213, 
0.00320436886283705, -0.0536161600234467, 0.0443090094724502, 
0.0262481114067995, 0.0281836519343494, 0.0197346073856975, 0.0518076006330598, 
0.0562204163423212, -0.0425203135287222, 0.0810735558499414, 
0.0811462107854631, 0.0627622574208675, 0.0582965271981243, 0.122061537397421, 
0.0967038661899179, 0.0497300142555686, -0.00433319015240328, 
0.0238870852051583, 0.0170609779484174, -0.00322052454865182, 
0.0322969785228605)), class = "data.frame", row.names = c(NA, 
-49L))

my code:

conin_test1 <- ca.jo(avi[,c(6:10)], type = "trace", ecdet = "none", spec = "longrun")
summary(conin_test1)

# Estimate VAR for avi
var_aic_avi96 <- VAR(avi[,c(2,6:10)], type = "const", lag.max = 7, season = 12)

# Lag order suggested by AIC
var_aic_avi96$p

#AVI 96
est_tsdyn_avi96 <- VECM(avi[,-c(1,3:5)], lag = 5, r = 3, include = "none", estim = "ML",exogen =avi[,2] )

# Print results
summary(est_tsdyn_avi96)

var_avi96 <- vec2var(conin_test1, r = 3)

I want to use this function, but when I use it it takes only cointegrated variables, and I need also those exogenous variables that I took in est_tsdyn_avi96 model.

suppressWarnings({
plot(irf(var_avi96, response = c(""), impulse = c(""), boot = TRUE,ci=0.95))
})

Please help.

0

There are 0 best solutions below