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

forecast() doesn't back transform box_cox transformations when generating coherent forecasts using reconcile() #382

Open
shelby-mcneill-domo opened this issue Jun 20, 2023 · 0 comments

Comments

@shelby-mcneill-domo
Copy link

The following code doesn't automatically back transform a box_cox transformation when generating coherent forecasts using reconcile():

library(fable)
library(dplyr)
library(feasts)
library(tsibble)

UKLungDeaths <- as_tsibble(cbind(mdeaths, fdeaths), pivot_longer = TRUE)

UKLungDeaths_gts <- UKLungDeaths |>
  aggregate_key(key, value = sum(value))

lambda <- UKLungDeaths_gts |>
  features(value, features = guerrero)

train_data <- UKLungDeaths_gts |>
  left_join(lambda, by = "key") 

test_data <- new_data(UKLungDeaths_gts, 12) %>% 
  left_join(lambda)

train_data |>
  model(base = ETS(box_cox(value, lambda_guerrero))) |>
  reconcile(
    bottom_up = bottom_up(base),
    MinT = min_trace(base, method = "mint_shrink") ) |> forecast(test_data)

Snippet of forecast output:
image

I also tried setting the transformation to use only the first value of lambda, as mentioned in #103, but get the following error:

train_data |>
  model(base = ETS(box_cox(value, first(lambda_guerrero)))) |>
  reconcile(
    bottom_up = bottom_up(base),
    MinT = min_trace(base, method = "mint_shrink") ) |> forecast(test_data)

Error in `mutate()`:
ℹ In argument: `MinT = (function (object, ...) ...`.
Caused by error in `vec_size()`:
! object 'lambda_guerrero' not found

Thank you!

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