在 ARIMA 或 VAR 模型中选择特定的滞后 [英] Choosing specific lags in ARIMA or VAR Model
问题描述
我已经看到这个问题提出 这里和here 但不幸的是,答案并不令人满意.在 VAR
中的 p
参数或 arima
中的 order
参数中输入滞后,R 将包括所有滞后于或低于该规定值.
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.
但是,如果您只想要特定的延迟怎么办?例如,如果我只想在 VAR 中使用滞后 1、2 和 4 怎么办?在 VAR
中输入 P=4 会给我滞后 1、2、3 和 4,但我想排除第三个滞后.
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.
在第一个链接中,用户通过说明他可以使用季节性参数来包含滞后 1,2 和 4 来提供答案,因为他的数据是季度的,但这仅适用于特殊情况,不是通用解决方案.
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.
推荐答案
幸运的是,我们可以轻松地为这两个模型做到这一点.例如,在 ARIMA(3,0,3) 的情况下,这里是如何降低第二个 AR 滞后和第一个 MA 滞后:
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
这里的 fixed
是一个与参数总数长度相同的可选数字向量.如果提供,则只有固定中的 NA 条目会发生变化";有关警告等的更多详细信息,请参见 ?arima
.fixed
的每个元素对应于显示的系数向量(或 coef(arima(...))
),例如fixed[3]
对应ar3
,fixed[7]
对应intercept
.
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
.
同样,vars
中的 restrict
是 VAR 模型所需要的.同样,您必须指定您的限制,这次是在矩阵 resmat
中,例如让我们使用 VAR(2) 并删除 e
的第二个滞后和 prod
的第一个滞后:
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
resmat
的第一行对应第一个方程,所有系数都和无限制模型中的一样:e.l1, prod.l1, e.l2, prod.l2, const
,即 restrict[1, 5]
对应于截距,同样适用于第二个矩阵行.
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.
这篇关于在 ARIMA 或 VAR 模型中选择特定的滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!