与 mable 分开报告模型

Report models separately from a mable

如何从一个 mable 中单独报告每个模型。

示例代码(来自https://otexts.com/fpp3/holt-winters.html

library(fabletools)
library(fable)
library(forecast)
library(tsibble)
library(feasts)

aus_holidays <- tourism %>%
  filter(Purpose == "Holiday") %>%
  summarise(Trips = sum(Trips))

fit <- aus_holidays %>%
  model(
    additive = ETS(Trips ~ error("A") + trend("A") + season("A")),
    multiplicative = ETS(Trips ~ error("M") + trend("A") + season("M"))
  )
fc <- fit %>% forecast(h = "3 years")

fc %>%
  autoplot(aus_holidays, level = NULL) + xlab("Year") +
  ylab("Overnight trips (millions)") +
  scale_color_brewer(type = "qual", palette = "Dark2")

在上面的例子中,我想分别报告加法模型和乘法模型。我试过 report(fc$additive) 但这不起作用。或者,我可以一次适合一个模型,并且 report(fc).

如果我们使用 report(fc),我们会收到一条非常有用的警告消息:

> fit %>% report()
# A tibble: 2 x 9
  .model               sigma2 log_lik   AIC  AICc   BIC     MSE    AMSE      MAE
  <chr>                 <dbl>   <dbl> <dbl> <dbl> <dbl>   <dbl>   <dbl>    <dbl>
1 additive       189416.        -657. 1332. 1335. 1354. 170475. 180856. 315.    
2 multiplicative      0.00213   -657. 1332. 1334. 1353. 171077. 182840.   0.0331
Warning message:
In report.mdl_df(.) :
  Model reporting is only supported for individual models, so a glance will be shown. To see the report for a specific model, use `select()` and `filter()` to identify a single model.

如果我们遵循该建议,我们将获得关于各个模型的报告输出。

> fit %>% select(additive) %>% report()
Series: Trips 
Model: ETS(A,A,A) 
  Smoothing parameters:
    alpha = 0.236428 
    beta  = 0.02978683 
    gamma = 0.0001000204 

  Initial states:
        l         b        s1        s2        s3      s4
 9898.697 -37.39721 -538.1971 -683.9969 -289.7464 1511.94

  sigma^2:  189416.5

     AIC     AICc      BIC 
1332.270 1334.841 1353.708 
> fit %>% select(multiplicative) %>% report()
Series: Trips 
Model: ETS(M,A,M) 
  Smoothing parameters:
    alpha = 0.1864709 
    beta  = 0.02476546 
    gamma = 0.0001001247 

  Initial states:
        l         b        s1        s2        s3      s4
 9852.791 -33.41186 0.9425605 0.9255899 0.9699594 1.16189

  sigma^2:  0.0021

     AIC     AICc      BIC 
1331.853 1334.424 1353.291