简体   繁体   English

tidyverts 中的分层建模/协调问题

[英]Problems with hierarchical modelling/reconciliation in tidyverts

I'm trying to do hierarchical forecasting after the fashion of Rob Hyndman's Rstudio.conf workshop , and running into some problems.我正在尝试按照Rob Hyndman 的 Rstudio.conf 研讨会的方式进行分层预测,但遇到了一些问题。 Here is my code:这是我的代码:

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()

The output of the plot is below. plot 的 output 如下。

在此处输入图像描述

My main problems are:我的主要问题是:

  • The reconciliation doesn't actually seem to have changed the forecasts at all.和解实际上似乎根本没有改变预测。 The picture indicates that the ar and ar_adj lines are identical.图片表明arar_adj行是相同的。
  • The forecast is only for the time period 2014 to 2015, whereas I know that the full dataset goes to 2018.预测仅适用于 2014 年至 2015 年的时间段,而我知道完整的数据集到 2018 年。

How can I fix these?我该如何解决这些问题? The latter one is probably because not all the time series cover the entire period, but how can I get reconcile to not skip over missing periods?后一个可能是因为并非所有时间序列都涵盖整个时期,但我怎样才能reconcile不跳过缺失的时期?

This is with dplyr 0.8.5, fable 0.2.0, fabletools 0.1.3 and tsibble 0.8.6.这是 dplyr 0.8.5、fable 0.2.0、fabletools 0.1.3 和 tsibble 0.8.6。 I get the same results on both Ubuntu/R 3.6.3 and Windows 10/R 4.0.0.我在 Ubuntu/R 3.6.3 和 Windows 10/R 4.0.0 上得到了相同的结果。

PS. PS。 Trying to forecast for a fixed horizon results in an error:尝试对固定范围进行预测会导致错误:

> 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.

These issues are bugs (or more-so out of scope for the current reconciliation implementation).这些问题是错误(或者更多的是当前对帐实施的 scope)。 You can report these via the package's BugReports URL ( https://github.com/tidyverts/fabletools/issues ).您可以通过包的 BugReports URL ( https://github.com/tidyverts/fabletools/issues ) 报告这些问题。

My main problems are:我的主要问题是:

The reconciliation doesn't actually seem to have changed the forecasts at all.和解实际上似乎根本没有改变预测。 The picture indicates that the ar and ar_adj lines are identical.图片表明 ar 和 ar_adj 行是相同的。

The forecast is only for the time period 2014 to 2015, whereas I know that the full dataset goes to 2018.预测仅适用于 2014 年至 2015 年的时间段,而我知道完整的数据集到 2018 年。

The forecasts for the reconciled models should have errored, which is the current behaviour in the development version.协调模型的预测应该有错误,这是开发版本中的当前行为。 Note that your forecast() new_data argument contains 148 time series, but you're producing forecasts from 181 models.请注意,您的forecast() new_data参数包含 148 个时间序列,但您正在从 181 个模型生成预测。 This is because the requested forecasts are for bottom level series only ( aus_retail_2013_vl has not been aggregated).这是因为请求的预测仅适用于底层系列( aus_retail_2013_vl尚未汇总)。

PS. PS。 Trying to forecast for a fixed horizon results in an error:尝试对固定范围进行预测会导致错误:

 Error: Reconciliation of non-normal forecasts is not yet supported. Run `rlang::last_error()` to see where the error occurred.```

This is because your model has a log transformed response variable, which when backtransformed produces forecasts that have a logNormal distribution.这是因为您的 model 具有对数转换的响应变量,该变量在进行反向转换时会产生具有对数正态分布的预测。 Probabilistic forecast reconciliation is difficult, and is currently only implemented for normal distributions.概率预测协调很困难,目前仅针对正态分布实施。 I will add reconciliation on point forecasts as a fall back ( https://github.com/tidyverts/fabletools/issues/216 ).我将添加对点预测的协调作为后备( https://github.com/tidyverts/fabletools/issues/216 )。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM