简体   繁体   English

为什么预测 function 从 package fabletools (R) back transform log(.) 但不是 box_cox(., lambda)

[英]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.

相关问题 为什么常量 `fabletools` 与 `forecast` 包(ARIMA 模型)中的平均值不同? - Why is the constant `fabletools` different from the mean in `forecast` package (ARIMA model)? fabletools::forecast 函数失败 - fabletools::forecast function fails 在R中寻找Box-Cox变换的最优Lambda - Finding Optimal Lambda for Box-Cox Transform in R 未嵌套<dist>来自 `fatabletools::forecast()` 的列 output</dist> - Unnest <dist> column from `fabletools::forecast()` output 给定一个具有多个键的 tsibble,tidyverts 是否能够使用每个时间序列的相应 lambda_guerrero 值对每个时间序列进行 box_cox()? - Given a tsibble with more than one key, is tidyverts able to box_cox() each time series using a respective lambda_guerrero value per time series? 从 fabletools package 中的精度 function 获取 null 结果 - Getting null results from the accuracy function in fabletools package 为什么NSDIFFS(R预测软件包)从不显示季节性? - Why does NSDIFFS (R forecast package) never show seasonality? 如何从tbats函数获取模型名称,R中的预测包 - how to get model name from tbats function, forecast package in R 使用r中预测包的精度函数进行MASE计算 - MASE calculation using accuracy function from forecast package in r 优化Box-cox转换,无法在初始参数处评估功能 - Optimize box-cox transform, function cannot be evaluated at initial parameters
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM