Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Choosing specific lags in ARIMA or VAR Model

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.

like image 281
gtnbz2nyt Avatar asked Mar 26 '14 12:03

gtnbz2nyt


1 Answers

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:

arima(lh, order = c(3, 0, 3), fixed = c(NA, 0, NA, 0, NA, NA, NA))

Call:
arima(x = lh, order = c(3, 0, 3), fixed = c(NA, 0, NA, 0, NA, NA, NA))

Coefficients:
         ar1  ar2      ar3  ma1      ma2      ma3  intercept
      0.6687    0  -0.1749    0  -0.0922  -0.1459     2.3909
s.e.  0.1411    0   0.1784    0   0.1788   0.2415     0.0929

sigma^2 estimated as 0.1773:  log likelihood = -26.93,  aic = 65.87
Warning message:
In arima(lh, order = c(3, 0, 3), fixed = c(NA, 0, NA, 0, NA, NA,  :
  some AR parameters were fixed: setting transform.pars = FALSE

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 of fixed corresponds to the respective element from the displayed vector of coefficients (or coef(arima(...))), e.g. fixed[3] corresponds to ar3 and fixed[7] to intercept.

Similarly, restrict from vars is what you need for VAR models. Again, you have to specify yours restrictions, this time in the matrix resmat, e.g. let us take VAR(2) and drop the second lag of e and the first of prod:

data(Canada)
model <- VAR(Canada[, 1:2], p = 2, type = "const")
restrict <- matrix(c(1, 0, 0, 1, 1, 
                     1, 0, 0, 1, 1),
                   nrow = 2, ncol = 5, byrow = TRUE)
coef(restrict(model, method = "man", resmat = restrict))
$e
          Estimate Std. Error   t value     Pr(>|t|)
e.l1     0.9549881 0.01389252 68.741154 3.068870e-72
prod.l2  0.1272821 0.03118432  4.081607 1.062318e-04
const   -8.9867864 6.46303483 -1.390490 1.682850e-01

$prod
            Estimate  Std. Error   t value     Pr(>|t|)
e.l1      0.04130273  0.02983449  1.384396 1.701355e-01
prod.l2   0.94684968  0.06696899 14.138628 2.415345e-23
const   -17.02778014 13.87950374 -1.226829 2.235306e-01

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.

like image 116
Julius Vainora Avatar answered Oct 18 '22 23:10

Julius Vainora