对于以后会遇到这种情况的其他人,我已经粘贴了一个适用于我最新版本的 fable/fabletools 的解决方案。
library(fable)
#> Loading required package: fabletools
library(tsibble)
library(tsibbledata)
library(lubridate)
#>
#> Attaching package: 'lubridate'
#> The following object is masked from 'package:tsibble':
#>
#> interval
#> The following objects are masked from 'package:base':
#>
#> date, intersect, setdiff, union
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
library(tidyr)
aus_retail %>%
filter(
State %in% c("New South Wales", "Victoria"),
Industry == "Department stores"
) %>%
model(
ets = ETS(box_cox(Turnover, 0.3)),
arima = ARIMA(log(Turnover)),
snaive = SNAIVE(Turnover)
) %>%
pivot_longer(cols = -c(State, Industry),
names_to = "model_type",
values_to = "model_specifics_mdl") %>%
mutate(model_specifics = format(model_specifics_mdl)) %>%
select(-model_specifics_mdl)
#> # A tibble: 6 x 4
#> State Industry model_type model_specifics
#> <chr> <chr> <chr> <chr>
#> 1 New South Wales Department stores ets <ETS(A,Ad,A)>
#> 2 New South Wales Department stores arima <ARIMA(2,1,1)(2,1,1)[12]>
#> 3 New South Wales Department stores snaive <SNAIVE>
#> 4 Victoria Department stores ets <ETS(A,A,A)>
#> 5 Victoria Department stores arima <ARIMA(2,1,1)(1,1,2)[12]>
#> 6 Victoria Department stores snaive <SNAIVE>
由reprex 包(v0.3.0)于 2020 年 9 月 7 日创建