指定季节性ARIMA

时间:2018-03-15 12:49:01

标签: r arima

我有一些预测:: Arima语法问题。如果我知道季节性ARIMA在统计上是正确的,因为它是auto.arima的结果,我如何修复以下Arima函数以获得与auto.arima结果相同的顺序:

library(forecast)

set.seed(1)
y <- sin((1:40)) * 10 + 20 + rnorm(40, 0, 2)
my_ts <- ts(y, start = c(2000, 1), freq = 12)

fit_auto <- auto.arima(my_ts, max.order = 2)
plot(forecast(fit_auto, h = 24))
# Arima(0,0,1)(1,0,0) with non-zero mean

fit_arima <- Arima(my_ts,
                   order = c(0, 0, 1),
                   seasonal = list(c(1, 0, 0)))
#Error in if ((order[2] + seasonal$order[2]) > 1 & include.drift) { : 
#  argument is of length zero

Thx&amp;亲切的问候

1 个答案:

答案 0 :(得分:3)

seasonal的参数必须是给出季节性顺序的数字向量,或者是包含两个命名元素的列表:order,给出季节性顺序的数字向量,以及period ,一个给出季节性周期的整数。

您提供的列表中只包含季节性订单,因此Arima抱怨它无法找到period值。如果您提供数字向量,period将默认为frequency(my_ts),就像在函数文档中所述。虽然仅将订单作为数字或列表给出应该具有相同的结果是有意义的,但它并没有。只是这个功能的一个怪癖。

重写您的通话有效:

fit_arima <- Arima(my_ts,
                   order = c(0, 0, 1),
                   seasonal = c(1, 0, 0)) # vector, not a list