[英]why does forecast function from package fabletools (R) back transform log(.) but not box_cox(., lambda)
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 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.
它对 log 转换这样做,但不是 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)由代表 package (v2.0.1) 于 2022 年 1 月 3 日创建
Found the solution here: https://github.com/tidyverts/fabletools/issues/103 Hope this helps someone else.在这里找到解决方案: https://github.com/tidyverts/fabletools/issues/103希望这对其他人有帮助。 The crux of the issue is that you need to supply the value of lambda for the forecast period.
问题的症结在于您需要在预测期间提供 lambda 的值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.