-
Notifications
You must be signed in to change notification settings - Fork 36
Description
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.