tidyverts / feasts

Feature Extraction And Statistics for Time Series
https://feasts.tidyverts.org/
291 stars 23 forks source link

Error when forecasting with STL decomposition #90

Closed markfairbanks closed 4 years ago

markfairbanks commented 4 years ago

After the new update to STL decompositions, an error occurs when trying to use forecast():

library(fpp3)
#> ── Attaching packages ──────────────────────────────────────────────────────────────────────────────── fpp3 0.1 ──
#> ✓ tibble      2.1.3     ✓ tsibble     0.8.6
#> ✓ dplyr       0.8.4     ✓ tsibbledata 0.1.0
#> ✓ tidyr       1.0.2     ✓ feasts      0.1.2
#> ✓ lubridate   1.7.4     ✓ fable       0.1.2
#> ✓ ggplot2     3.2.1

tsibbledata::aus_retail %>%
  filter(`Series ID` == "A3349849A") %>%
  model(stl = STL(Turnover)) %>%
  forecast(h = 12)
#> Error in UseMethod("forecast"): no applicable method for 'forecast' applied to an object of class "stl_decomposition"

Created on 2020-02-21 by the reprex package (v0.3.0)

markfairbanks commented 4 years ago

I figured out the error - you still have to specify the intent to use the decomposition as a model to forecast with:

library(fpp3)

tsibbledata::aus_retail %>%
  filter(`Series ID` == "A3349849A") %>%
  model(stl = decomposition_model(
    STL(Turnover),
    ETS(season_adjust))) %>%
  forecast(h = 12)

Sorry for the unnecessary issue!