`stream()` errors with ARIMA uninformatively
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 588
- Forks
- 71
- Avg merge
- 1h 58m
- Merged PRs (30d)
- 1
Description
I'd expect stream() to work similarly to refit() based on the documentation, but I get an error. Maybe it's just not supported yet, like ETS, and is supposed to fail faster with an informative error?
# Automatic ARIMA specification
library(tsibble)
#>
#> Attaching package: 'tsibble'
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, union
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(fable)
#> Loading required package: fabletools
library(fabletools)
data_full <- tsibbledata::global_economy
data_train <- data_full |> filter(Year < 2015)
data_stream <- data_full |> filter(Year >= 2015)
mod <-
data_train %>%
filter(Country == "Australia") %>%
model(ARIMA(log(GDP) ~ Population))
#> Warning in sqrt(diag(best$var.coef)): NaNs produced
refit(mod, data_full)
#> # A mable: 1 x 2
#> # Key: Country [1]
#> Country `ARIMA(log(GDP) ~ Population)`
#> <fct> <model>
#> 1 Australia <LM w/ ARIMA(1,0,1) errors>
stream(mod, data_stream)
#> Error in `mutate()`:
#> ! Problem while computing `ARIMA(log(GDP) ~ Population) = (function
#> (object, ...) ...`.
#> Caused by error in `if (self$stage %in% c("estimate", "refit")) ...`:
#> ! argument is of length zero
#> Backtrace:
#> ▆
#> 1. ├─fabletools::stream(mod, data_stream)
#> 2. ├─fabletools:::stream.mdl_df(mod, data_stream)
#> 3. │ └─dplyr::mutate_at(object, vars(!!!mdls), stream, new_data, ...)
#> 4. │ ├─dplyr::mutate(.tbl, !!!funs)
#> 5. │ └─dplyr:::mutate.data.frame(.tbl, !!!funs)
#> 6. │ └─dplyr:::mutate_cols(.data, dplyr_quosures(...), caller_env = caller_env())
#> 7. │ ├─base::withCallingHandlers(...)
#> 8. │ └─mask$eval_all_mutate(quo)
#> 9. ├─fabletools (local) `<fn>`(`ARIMA(log(GDP) ~ Population)`, `<list>`)
#> 10. ├─fabletools:::stream.lst_mdl(`ARIMA(log(GDP) ~ Population)`, `<list>`)
#> 11. │ ├─fabletools:::add_class(map2(object, new_data, stream, ...), class(object))
#> 12. │ └─fabletools:::map2(object, new_data, stream, ...)
#> 13. │ └─base::mapply(.f, .x, .y, MoreArgs = list(...), SIMPLIFY = FALSE)
#> 14. │ ├─fabletools (local) `<fn>`(dots[[1L]][[1L]], dots[[2L]][[1L]])
#> 15. │ └─fabletools:::stream.mdl_ts(dots[[1L]][[1L]], dots[[2L]][[1L]])
#> 16. │ └─fabletools:::parse_model_rhs(object$model)
#> 17. │ └─fabletools:::map(...)
#> 18. │ └─base::lapply(.x, .f, ...)
#> 19. │ └─fabletools (local) FUN(X[[i]], ...)
#> 20. │ └─fabletools:::map(.x, eval_tidy, data = model$data, env = model$specials)
#> 21. │ └─base::lapply(.x, .f, ...)
#> 22. │ └─rlang (local) FUN(X[[i]], ...)
#> 23. ├─fable (local) pdq()
#> 24. └─base::.handleSimpleError(...)
#> 25. └─dplyr (local) h(simpleError(msg, call))
#> 26. └─rlang::abort(...)
Created on 2022-12-09 with reprex v2.0.2
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied reprex and comparing refit() with fabletools::stream(), then trace the stream.mdl_df and stream.mdl_ts entry points shown in the backtrace. Confirm whether ARIMA models support streaming and make the unsupported case fail with an informative error, or verify the expected streaming behavior with a regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100