Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream() errors with ARIMA uninformatively #373

Open
Aariq opened this issue Dec 9, 2022 · 0 comments
Open

stream() errors with ARIMA uninformatively #373

Aariq opened this issue Dec 9, 2022 · 0 comments

Comments

@Aariq
Copy link

Aariq commented Dec 9, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant