如何预测时间序列,包括R中的季节性因素 [英] How to forecast time series, including a seasonality factor in R

查看:97
本文介绍了如何预测时间序列,包括R中的季节性因素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下示例数据:

library(data.table)
dt <- data.table('time' = c(1:10),
                    'units'= c(89496264,81820040,80960072,109164545,96226255,96270421,95694992,117509717,105134778,0))

我想在 time = 10 时对 units 进行 forecast .

我可以看到在 time = 4 * k 的情况下,其中 k = 1,2,... 的单位大大增加了,我想将其作为季节性因素.

I can see that at time = 4*k, where k = 1,2,... there is a big increase of units, and I would like to include that as a seasonality factor.

如何在 R 中执行此操作?我已经研究了 auto.arima ,但似乎这不是要走的路.

How could I do that in R ? I have looked into the auto.arima but it seems that is it not the way to go.

谢谢

推荐答案

先知 API可让您使用加法模型轻松计算预测,该模型将非线性趋势与每年,每周和每天的季节性相吻合.

The Prophet API lets you compute easily the predictions, with an additive model where non-linear trends are fit with yearly, weekly, and daily seasonality.

从上面的链接中引用:

最适合具有强烈季节性影响和多个季节历史数据的时间序列.先知对于丢失数据和趋势变化具有较强的鲁棒性,并且通常能够很好地处理异常值.

It works best with time series that have strong seasonal effects and several seasons of historical data. Prophet is robust to missing data and shifts in the trend, and typically handles outliers well.

install.packages(‘prophet’)
library(prophet)
model <- prophet(dt) # see ?prophet for details, this builds the model (like auto.arima)
future <- make_future_dataframe(model, periods = 10) # creates the "future" data 
forecast <- predict(model, future) # predictions

tail(forecast)

此处完整R中的示例.

这篇关于如何预测时间序列,包括R中的季节性因素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆