简体   繁体   English

与 mable 分开报告模型

[英]Report models separately from a mable

How can I report each model seperately from a mable.如何将每个 model 与 mable 分开报告。

Example code (from https://otexts.com/fpp3/holt-winters.html )示例代码(来自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")

In above example, I want to report the additive model and multiplicative model separately.在上面的例子中,我想分别报告加法 model 和乘法 model。 I tried report(fc$additive) but that does not work.我尝试report(fc$additive)但这不起作用。 Alternatively, I can fit one model at a time, and report(fc) .或者,我可以一次安装一个 model 和report(fc)

If we use report(fc) we get a very helpful warning message:如果我们使用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.

If we follow that advice, we get report output on individual models.如果我们遵循该建议,我们会收到有关各个型号的报告 output。

> 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM