tidyverts / fabletools

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

How is stream() intended to be used? #359

Closed dclambiata closed 1 year ago

dclambiata commented 2 years ago

Hi, thanks for all this great work. I've got a question about the stream() function, which follows up issue https://github.com/tidyverts/fabletools/issues/328 . How is stream() intended to be used? The example in the vignette doesn't work, and the example I've got below also fails.

# Init
library(tidyverse)
library(fable)
#> Loading required package: fabletools

# Prepare data
us_accidental_deaths <- as_tsibble(USAccDeaths)
deaths_train <- head(us_accidental_deaths, -24)
deaths_test <- tail(us_accidental_deaths, 24)

# Get models on training data
deaths_fits_0 <- deaths_train %>% 
    model(
        ets = ETS(value),
        arima = ARIMA(value)
    )

deaths_fits_0 %>%
    stream(new_data=deaths_test)
#> Error in `mutate()`:
#> ! Problem while computing `ets = (function (object, ...) ...`.
#> Caused by error in `UseMethod()`:
#> ! no applicable method for 'stream' applied to an object of class "ETS"
Created on 2022-06-01 by the reprex package (v2.0.1)
mitchelloharawild commented 2 years ago

Hi, the stream() method is intended to work as you have described above - however the method isn't implemented for many models yet (including both ETS and ARIMA).

The intention is for stream() to update the fit of a model to incorporate new observations without changing the estimates of the model (similar to refit() but slightly more efficient).

In practice it is a bit tricky to implement, so it will take time for these methods to be written. The stream method for ARIMA is 95% complete, and I haven't started on ETS yet.