R使用stl和arima预测季节和数据趋势

R forecast season and trend of data using stl and arima

我有一个包含季节性成分、趋势和 arma 部分的数据系列。我想根据历史来预测这个系列。

我可以使用程序

data_ts <- ts(data, frequency = 24)
data_deseason <- stl(data_ts, t.window=50, s.window='periodic', robust=TRUE) 
f <- forecast(data_deseason, method='arima', h = N)

但是在这样做时我无法选择我想要的 Arima 部分的参数。上面似乎使用了类似 auto.arima 的东西,因为我自己选择了 arima 参数 - 但它运行得非常快并且比 auto.arima 快得多 - 所以不确定会发生什么。

或者,我可以使用上面的方法将数据分成季节、趋势和剩余部分。但是我该如何预测呢?我应该为趋势和剩余部分制作一个 arma 模型吗?

trend_arima <- Arima(data_deseason$time.series[,'trend'], order = c(1,1,1))
remainder_arima <- Arima(data_deseason$time.series[,'remainder'], order = c(1,1,1))

然后使用 forecast() 并添加以上两个组件和季节。或者有什么方法可以提取stl找到的趋势模型吗?

感谢任何提示:) 本杰明

forecast.stl 函数正在对余数系列使用 auto.arima。它很快,因为它不需要考虑季节性 ARIMA 模型。

您可以通过 forecastfunction 参数 select 具有特定参数的特定模型。例如,假设您想使用参数为 0.7 的 AR(1),可以使用以下代码:

data_ts <- ts(data, frequency = 24)
data_deseason <- stl(data_ts, t.window=50, s.window='periodic', robust=TRUE) 
f <- forecast(data_deseason, h=N,
        forecastfunction=function(x,h,level){
        fit <- Arima(x, order=c(1,0,0), fixed=0.7, include.mean=FALSE)
        return(forecast(fit,h=N,level=level))})
plot(f)

如果您只想 select ARIMA 阶数,而不是参数,则省略 fixed 参数。