Hon*_*Ooi 7 r forecasting fable-r tidyverts
我正在尝试按照Rob Hyndman 的 Rstudio.conf 研讨会的方式进行分层预测,但遇到了一些问题。这是我的代码:
library(dplyr)
library(tsibbledata)
library(tsibble)
library(fable)
aus_retail_2013_tr <- aus_retail %>%
filter(Month <= yearmonth("2013 Dec"))
aus_retail_2013_vl <- aus_retail %>%
filter(Month > yearmonth("2013 Dec"))
hmod <- aus_retail_2013_tr %>%
aggregate_key(State*Industry, Turnover=sum(Turnover)) %>%
model(ar=ARIMA(log(Turnover))) %>%
reconcile(ar_adj=min_trace(ar))
fcasts_hmod <- forecast(hmod, aus_retail_2013_vl)
fcasts_hmod %>%
filter(is_aggregated(Industry), State == "Victoria") %>%
autoplot()
Run Code Online (Sandbox Code Playgroud)
该图的输出如下。
我的主要问题是:
ar和ar_adj线是相同的。我该如何解决这些问题?后一个可能是因为并非所有时间序列都涵盖整个时期,但我怎样才能reconcile不跳过缺失的时期?
这是 dplyr 0.8.5、fable 0.2.0、fabletools 0.1.3 和 tsibble 0.8.6。我在 Ubuntu/R 3.6.3 和 Windows 10/R 4.0.0 上得到相同的结果。
附注。尝试预测固定范围会导致错误:
> fcasts_hmod <- forecast(hmod, h="5 years")
Error: Reconciliation of non-normal forecasts is not yet supported.
Run `rlang::last_error()` to see where the error occurred.
Run Code Online (Sandbox Code Playgroud)
这些问题都是错误(或者更严重的是超出了当前协调实施的范围)。您可以通过包的 BugReports URL ( https://github.com/tidyverts/fabletools/issues ) 报告这些问题。
我的主要问题是:
实际上,这次调节似乎根本没有改变预测。该图表明 ar 和 ar_adj 行是相同的。
预测仅针对 2014 年至 2015 年期间,而我知道完整数据集截至 2018 年。
协调模型的预测应该有错误,这是开发版本中的当前行为。请注意,您的forecast() new_data参数包含 148 个时间序列,但您正在根据 181 个模型生成预测。这是因为请求的预测仅适用于底层序列(aus_retail_2013_vl尚未聚合)。
附言。尝试预测固定范围会导致错误:
Run Code Online (Sandbox Code Playgroud)Error: Reconciliation of non-normal forecasts is not yet supported. Run `rlang::last_error()` to see where the error occurred.```
这是因为您的模型具有对数转换响应变量,该变量在反向转换时会生成具有对数正态分布的预测。概率预测协调很困难,目前仅针对正态分布实现。我将添加对点预测的调节作为后备(https://github.com/tidyverts/fabletools/issues/216)。