Reputation: 57
Hello Stack community,
I am building the vector autoregression model with three endogenous and one exogenous variables. As I obtain the coefficients using summary(model_name)
or Bcoef(model_name)
commands, the output contains the lagged values for endogenous variables, but only current value (no lags) of exogenous variable.
However, what I am interested in is the effect of exogenous variable, hence the current and lagged coefficients of exogenous variable, but unfortunately no lags are provided.
I would greatly appreciate if someone has an idea how to obtain these coefficients? Is there a separate package for it (as a matter of fact, to draw impulse response function for exogenous variable, separate package is needed)? or if not the package, how else shall I deal with this issue?
Upvotes: 1
Views: 827
Reputation: 338
Exogenous variable are not affected by lags input in VAR model, so if you want to create and exogenous variable with lagged you will have to introduce each of this one by one, create a data frame with the lagged values:
library(vars)
#> Loading required package: MASS
#> Loading required package: strucchange
#> Loading required package: zoo
#>
#> Attaching package: 'zoo'
#> The following objects are masked from 'package:base':
#>
#> as.Date, as.Date.numeric
#> Loading required package: sandwich
#> Loading required package: urca
#> Loading required package: lmtest
library(magrittr)
data("Canada")
e <- Canada[,1]
prod <- Canada[,2]
rw <- Canada[,3]
exog <- Canada[,4]
exog_1 <- lag(exog,-1)
exog_2 <- lag(exog,-2)
data <- cbind(e,prod,rw,exog,exog_1,exog_2) %>%
na.omit()
VAR(data[,1:3],exogen = data[,4:6])
#>
#> VAR Estimation Results:
#> =======================
#>
#> Estimated coefficients for equation e:
#> ======================================
#> Call:
#> e = e.l1 + prod.l1 + rw.l1 + const + exog + exog_1 + exog_2
#>
#> e.l1 prod.l1 rw.l1 const exog exog_1
#> 1.02017830 0.05614693 -0.01826264 -34.21688327 -0.93864073 0.79002397
#> exog_2
#> 0.22434453
#>
#>
#> Estimated coefficients for equation prod:
#> =========================================
#> Call:
#> prod = e.l1 + prod.l1 + rw.l1 + const + exog + exog_1 + exog_2
#>
#> e.l1 prod.l1 rw.l1 const exog
#> 0.16469624 0.99378315 -0.05301798 -133.87969507 0.17191734
#> exog_1 exog_2
#> -0.30238907 0.60487385
#>
#>
#> Estimated coefficients for equation rw:
#> =======================================
#> Call:
#> rw = e.l1 + prod.l1 + rw.l1 + const + exog + exog_1 + exog_2
#>
#> e.l1 prod.l1 rw.l1 const exog exog_1
#> 0.17297620 -0.07327839 0.92329491 -99.55107991 0.49728306 -0.15506299
#> exog_2
#> -0.24236800
Created on 2022-02-11 by the reprex package (v1.0.0)
This is posible but not usual, remember to test if exog variable is really exogenous.
Upvotes: 1