I've seen this issue raised here and here but unfortunately the answers are not satisfactory. Inputting the lags in either the p
argument in VAR
or the order
argument in arima
, R will include all the lags at and below that stated value.
However, what if you want specific lags only? For example, what if I wanted lags 1, 2, and 4 only in a VAR? Inputting P=4 in VAR
will give me lags 1,2,3 and 4, but I would like to exclude the third lag.
In the first link, the user provided an answer by stating he can use the seasonal parameter to include lags 1,2 and 4 since his data is quarterly, however that is only for a special case and is not a general solution.
Fortunately, we can easily do this for both models. For example, in case of ARIMA(3,0,3) here is how to drop the second AR lag and the first MA lag:
Here
fixed
is an "optional numeric vector of the same length as the total number of parameters. If supplied, only NA entries in fixed will be varied"; see?arima
for more details about the warning, etc. Each element offixed
corresponds to the respective element from the displayed vector of coefficients (orcoef(arima(...))
), e.g.fixed[3]
corresponds toar3
andfixed[7]
tointercept
.Similarly,
restrict
fromvars
is what you need for VAR models. Again, you have to specify yours restrictions, this time in the matrixresmat
, e.g. let us take VAR(2) and drop the second lag ofe
and the first ofprod
:The first row of
resmat
corresponds to the first equation and all the coefficients go just as in the unrestricted model:e.l1, prod.l1, e.l2, prod.l2, const
, i.e.restrict[1, 5]
corresponds to the intercept and the same holds for the second matrix row.