1

It was my impression that the forecast function from the R package fabletools automatically back transformed forecasts: "If the response variable has been transformed in the model formula, the transformation will be automatically back-transformed". It does so for the log transform, but not box_cox. Am I missing something obvious?

library(fpp3)
#> ── Attaching packages ──────────────────────────────────────────── fpp3 0.4.0 ──
#> ✓ tibble      3.1.6     ✓ tsibble     1.1.0
#> ✓ dplyr       1.0.7     ✓ tsibbledata 0.3.0
#> ✓ tidyr       1.1.4     ✓ feasts      0.2.2
#> ✓ lubridate   1.8.0     ✓ fable       0.3.1
#> ✓ ggplot2     3.3.5
#> ── Conflicts ───────────────────────────────────────────────── fpp3_conflicts ──
#> x lubridate::date()    masks base::date()
#> x dplyr::filter()      masks stats::filter()
#> x tsibble::intersect() masks base::intersect()
#> x tsibble::interval()  masks lubridate::interval()
#> x dplyr::lag()         masks stats::lag()
#> x tsibble::setdiff()   masks base::setdiff()
#> x tsibble::union()     masks base::union()
library(dplyr)
lambda <- us_employment %>%
  features(Employed, features = guerrero)%>%
  filter(!is.na(lambda_guerrero))%>%
  head(n = 2) 
#> Warning: 126 errors (1 unique) encountered for feature 1
#> [126] missing value where TRUE/FALSE needed
with_lambda <- left_join(lambda, us_employment)%>%
  as_tsibble(key = Series_ID, index = Month) 
#> Joining, by = "Series_ID"
box_fit <- with_lambda %>%
  model(box_model = ARIMA(box_cox(Employed, lambda_guerrero)))
box_fcast <- box_fit %>%
    forecast(h = "3 years")
log_fit <- with_lambda %>%
  model(log_model = ARIMA(log(Employed)))
log_fcast <- log_fit %>%
  forecast(h = "3 years")
autoplot(filter(us_employment, Series_ID=="CEU0500000001"))+
  autolayer(filter(box_fcast, Series_ID=="CEU0500000001"))+
  autolayer(filter(log_fcast, Series_ID=="CEU0500000001"))
#> Plot variable not specified, automatically selected `.vars = Employed`

Created on 2022-01-03 by the reprex package (v2.0.1)

1 Answers1

2

Found the solution here: https://github.com/tidyverts/fabletools/issues/103 Hope this helps someone else. The crux of the issue is that you need to supply the value of lambda for the forecast period.

  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 04 '22 at 09:07