tidyverts / feasts

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

Error: Objects of type mdl_defn/R6 not supported by autoplot. #141

Closed verajosemanuel closed 3 years ago

verajosemanuel commented 3 years ago

followed example from slides here:

https://slides.mitchelloharawild.com/user2019/#13

aus_travel <- tourism %>% 
  group_by(Purpose) %>% 
  summarise(Trips = sum(Trips))

aus_travel_stl <- aus_travel %>% 
  STL(Trips ~ season(window = "periodic"))

aus_travel_stl %>% 
  autoplot()

Error: Objects of type mdl_defn/R6 not supported by autoplot.

mitchelloharawild commented 3 years ago

Thanks for letting me know, the code in these slides need updating.

Models that can decompose the data (such as STL()) are now considered 'models' and the decomposed components are obtained with components().

So the correct code should be:

library(fpp3)
#> ── Attaching packages ──────────────────────────────────────────── fpp3 0.4.0 ──
#> ✓ tibble      3.1.2          ✓ tsibble     1.0.1     
#> ✓ dplyr       1.0.6          ✓ tsibbledata 0.3.0     
#> ✓ tidyr       1.1.3          ✓ feasts      0.2.1.9000
#> ✓ lubridate   1.7.10         ✓ fable       0.3.1     
#> ✓ ggplot2     3.3.3.9000
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date()    masks base::date()
#> x dplyr::filter()      masks stats::filter()
#> x tsibble::intersect() masks base::intersect()
#> x tsibble::interval()  masks lubridate::interval()
#> x dplyr::lag()         masks stats::lag()
#> x tsibble::setdiff()   masks base::setdiff()
#> x tsibble::union()     masks base::union()
aus_travel <- tourism %>% 
  group_by(Purpose) %>% 
  summarise(Trips = sum(Trips))

aus_travel_stl <- aus_travel %>% 
  model(STL(Trips ~ season(window = "periodic"))) %>% 
  components()

aus_travel_stl %>% 
  autoplot()

Created on 2021-06-01 by the reprex package (v2.0.0)