【发布时间】:2021-02-27 23:01:11
【问题描述】:
我有一个每月的时间序列数据,我想使用 Fable 包中的不同模型对其进行建模,方法是使用交叉验证来了解所考虑模型中的最佳模型。
# My data
google <- read_csv("google.csv") %>%
tsibble(index = date)
# dimension of the data is 60 by 2.
]1
# Training data for cross validation
google_tr <- google %>%
slice(1:(n()-1)) %>%
stretch_tsibble(.init = 3, .step = 1)
# Building models for the data
fc <- google_tr %>%
model(ets = ETS(closing_price),
arima = ARIMA(closing_price),
rw = RW(closing_price ~ drift()),
prophet = prophet(closing_price)) %>%
forecast(h = "1 year")
出现了很多警告!
模型评估
fc %>% accuracy(google)
我已经阅读了https://otexts.com/fpp3/tscv.html 和https://otexts.com/fpp3/arima-ets.html#example-comparing-arima-and-ets-on-non-seasonal-data 没有数字的时间,但我仍然不知道如何选择正确的训练数据。如果我能在下面的块中为slice() 和stretch_tsibble() 获得正确的每月数据输入,那么问题将得到解决。
google_tr <- google %>%
slice(1:(n()-1)) %>%
stretch_tsibble(.init = 3, .step = 1)
【问题讨论】:
标签: r time-series cross-validation fable-r