How can I report each model seperately from a mable.
Example code (from 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. I tried report(fc$additive)
but that does not work. Alternatively, I can fit one model at a time, and report(fc)
.
If we use report(fc)
we get a very helpful warning message:
> 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.
> 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