在ARIMA或VAR模型中选择特定的滞后 [英] Choosing specific lags in ARIMA or VAR Model
问题描述
我已经看到此问题提出了此处,但不幸的是,答案并不令人满意.在VAR
的p
参数或arima
的order
参数中输入滞后,R将包括等于或低于该指定值的所有滞后.
但是,如果您只希望特定的滞后时间怎么办?例如,如果我只希望在VAR中滞后1、2和4,该怎么办?在VAR
中输入P = 4将给我1、2、3和4滞后,但是我想排除第三次滞后.
在第一个链接中,用户表示自己可以使用季节性参数来包括滞后时间1,2和4,从而提供了答案,因为他的数据是每季度一次,但这仅用于特殊情况,而不是一般的解决方案.
幸运的是,我们可以轻松地对两个模型执行此操作.例如,在ARIMA(3,0,3)的情况下,如何减少第二个AR滞后和第一个MA滞后:
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
.
类似地,vars
中的restrict
是VAR模型所需要的.同样,您必须在矩阵resmat
中指定您的限制,例如让我们取VAR(2)并除去e
的第二个滞后和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]
对应于截距,并且对第二个矩阵行具有相同的保持力./p>
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:
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.
这篇关于在ARIMA或VAR模型中选择特定的滞后的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!