bbi*_*gel 9 stl r time-series forecasting
我有一个数据系列,有季节性组件,趋势和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)
Run Code Online (Sandbox Code Playgroud)
但是在这样做的时候,我无法选择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))
Run Code Online (Sandbox Code Playgroud)
然后使用forecast()并添加上面两个组件和季节.或者有没有办法提取stl找到的趋势模型?
感谢任何提示:)本杰明
Rob*_*man 10
该forecast.stl函数auto.arima用于余数系列.它很快,因为它不需要考虑季节性ARIMA模型.
您可以通过forecastfunction参数选择具有特定参数的特定模型.例如,假设您想使用参数为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)
Run Code Online (Sandbox Code Playgroud)
如果您只想选择ARIMA订单而不是参数,那么请省略fixed参数.
| 归档时间: |
|
| 查看次数: |
6836 次 |
| 最近记录: |