tidyverts / tidyverts/fabletools
forecast() doesn't back transform box_cox transformations when generating coherent forecasts using reconcile()
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 98
- Forks
- 37
- PR merge metrics
- No merged PRs in 30d
Description
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:
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!
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
Run the supplied R example and trace forecast() after reconcile() with ETS(box_cox(...)); inspect how the transformation and lambda_guerrero are carried through the reconciliation result. Done means coherent forecasts are back transformed and the first(lambda_guerrero) variant no longer raises the reported missing-object error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100