如何在auto.arima中使用外部回归变量获得合适的模型

时间:2018-07-10 14:28:12

标签: r statistics time-series modeling forecasting

为了将其用作比较的基准,我正在尝试使用带有外部回归变量的ARIMA模型。我想插入虚拟变量以考虑每日的季节性。可以从下面呈现的数据图片中了解其原因。确实,在夜间,该值为零,我希望在模型中考虑此行为。

Beginning of the time series

可以在此处下载数据集:dataset_OneDrive

到目前为止,我尝试使用R中预测包中的auto.arima函数,如以下代码片段所示:

Y <- ts(data = Data_Exemple$value, frequency = 24)
hour_y <- hour(Data_Exemple$Date)
xreg_hour <- model.matrix((~as.factor(hour_y)))
colnames(xreg_hour) <- seq(1,24)

哪个给出了这样的外部回归变量:

##   1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
## 1 1 0 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## 2 1 1 0 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## 3 1 0 1 0 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## 4 1 0 0 1 0 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## 5 1 0 0 0 1 0 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0
## 6 1 0 0 0 0 1 0 0 0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0

然后我尝试拟合模型:

fit <- auto.arima(y = Y, D=1, d=0,seasonal = TRUE, trace = TRUE, xreg = xreg_hour)

Howewer无法找到合适的模型:

 Fitting models using approximations to speed things up...

 ARIMA(2,0,2)(1,1,1)[24] with drift         : Inf
 ARIMA(0,0,0)(0,1,0)[24] with drift         : Inf
 ARIMA(1,0,0)(1,1,0)[24] with drift         : Inf
 ARIMA(0,0,1)(0,1,1)[24] with drift         : Inf
 ARIMA(0,0,0)(0,1,0)[24]                    : Inf
 ARIMA(2,0,2)(0,1,1)[24] with drift         : Inf
 ARIMA(2,0,2)(2,1,1)[24] with drift         : Inf
 ARIMA(2,0,2)(1,1,0)[24] with drift         : Inf
 ARIMA(2,0,2)(1,1,2)[24] with drift         : Inf
 ARIMA(2,0,2)(0,1,0)[24] with drift         : Inf
 ARIMA(2,0,2)(2,1,2)[24] with drift         : Inf
 ARIMA(1,0,2)(1,1,1)[24] with drift         : Inf
 ARIMA(3,0,2)(1,1,1)[24] with drift         : Inf
 ARIMA(2,0,1)(1,1,1)[24] with drift         : Inf
 ARIMA(2,0,3)(1,1,1)[24] with drift         : Inf
 ARIMA(1,0,1)(1,1,1)[24] with drift         : Inf
 ARIMA(3,0,3)(1,1,1)[24] with drift         : Inf
 ARIMA(2,0,2)(1,1,1)[24]                    : Inf
 Show Traceback
Error in auto.arima(y = Y, D = 1, d = 0, seasonal = TRUE, trace = TRUE, : No suitable ARIMA model found

我的问题是:我在使用外部回归器时是否做错了明显的事情?我以为虚拟变量的数量可能是问题所在,但是使用一天晚上/一天的几个虚拟变量却无济于事。

如果某人有一些后见之明,我将很高兴知道!预先感谢!

0 个答案:

没有答案