tidyverts / fabletools

General fable features useful for extension packages
http://fabletools.tidyverts.org/
89 stars 31 forks source link

Cannot forecast of a reconciled ensemble model which includes prophet() #372

Closed ewlundstrom closed 8 months ago

ewlundstrom commented 1 year ago

I find that while I am able to forecast a reconciled ensemble forecast that does not include a prophet model, an error occurs when a prophet model is included.

Reproducible example:

library(tsibble)
library(tsibbledata)
library(remotes)
remotes::install_github("tidyverts/fable")
library(fable)
library(fabletools)
library(fable.prophet)

## Creating aggregate TS
Agg_Retail <- aus_retail %>% aggregate_key(State,
                                               Turnover = sum(Turnover))

## Ensemble Model without Prophet

Agg_Retail %>%
  model(Ensemble = combination_ensemble(ARIMA(Turnover),
                             ETS(Turnover),
                             weights = "inv_var")) %>%
  reconcile(min_trace(Ensemble)) %>%
  forecast(h = 12)

## Ensemble Model with Prophet

Agg_Retail %>%
  model(Ensemble = combination_ensemble(ARIMA(Turnover),
                                        ETS(Turnover),
                                        prophet(Turnover),
                                        weights = "inv_var")) %>%
  reconcile(min_trace(Ensemble)) %>%
  forecast(h = 12)

Error encountered:


! Problem with `mutate()` input `min_trace(Ensemble)`.
x min_trace needs covariance matrix to be positive definite.
i Input `min_trace(Ensemble)` is `(function (object, ...) ...`.
Run `rlang::last_error()` to see where the error occurred.
Warning message:
9 errors (1 unique) encountered for Ensemble
[9] .onLoad failed in loadNamespace() for 'processx', details:
  call: NULL
  error: 'ps_is_supported' is not an exported object from 'namespace:ps'```
mitchelloharawild commented 8 months ago

This should now be possible since ensemble models can now produce bootstrapped forecasts. This was added recently in dfc40110188094fe45c5d37e7fc9fdefba84519f.

To produce ensemble forecasts from models with different distributions, produce bootstrap or simulated sample paths with forecast(bootstrap = TRUE) or forecast(simulate = TRUE).