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

ARIMA(f) where f is a formula object - wrong model_lhs() #415

Open
kenahoo opened this issue Mar 8, 2025 · 0 comments
Open

ARIMA(f) where f is a formula object - wrong model_lhs() #415

kenahoo opened this issue Mar 8, 2025 · 0 comments

Comments

@kenahoo
Copy link

kenahoo commented Mar 8, 2025

The behavior of fabletools with formulas seems to have changed in some recent version. Using 0.5.0, I'm seeing the following behavior:

library(fable)
#> Loading required package: fabletools
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
library(fabletools)


fabletools:::model_lhs(ARIMA(target ~ x + y + z + pdq(0, 1, 0)))
#> target

# Should also give 'target', but gives 'f'
f <- target ~ x + y + z + pdq(0, 1, 0)
fabletools:::model_lhs(ARIMA(f))
#> f

packageVersion('fable')
#> [1] '0.4.0'
packageVersion('fabletools')
#> [1] '0.5.0'
R.version.string
#> [1] "R version 4.4.2 (2024-10-31)"

Created on 2025-03-08 with reprex v2.1.1

This is making it difficult to construct a formula based on dynamic criteria in the data. The blowup happens when using a combination_model(), and it's unable to determine that two models have the same LHS:

library(fable)
#> Loading required package: fabletools
#> Registered S3 method overwritten by 'tsibble':
#>   method               from 
#>   as_tibble.grouped_df dplyr
library(fabletools)

d <- tsibble::tsibble(date=as.Date("2017-01-01")+0:9, target=rnorm(10), x=runif(10))
#> Using `date` as index variable.
f1 <- formula('target ~ x + pdq(0, 1, 0)')
f2 <- formula('target ~ x + AR(p = 1, P = 0, period = 8766)')
fabletools::model(d, cmbn1=combination_model(ARIMA(f1), NNETAR(f2)))
#> Error in `combination_model()`:
#> ! `combination_model()` must use component models with the same response variable.

Created on 2025-03-08 with reprex v2.1.1

Is there a better recommended way to pass a formula object as an argument to ARIMA() (or NNETAR(), etc.) so it's properly understood by stuff like combination_model()? I believe that this did work properly in a previous version of fabletools (or one of the other packages), but I'm a bit uncertain which versions that would have been.

Thanks.

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