Standard fabletools / generics verbs for models fitted with
AIRLINE_DECOMPOSITION(), MSTL(), ISTL(), STLPLUS() and X11PLUS().
They can be applied directly on a mable.
Usage
# S3 method for class 'hf_model'
components(object, ...)
# S3 method for class 'hf_model'
model_sum(x)
# S3 method for class 'hf_model'
fitted(object, ...)
# S3 method for class 'hf_model'
residuals(object, type = c("innovation", "response"), ...)
# S3 method for class 'hf_model'
tidy(x, ...)
# S3 method for class 'hf_model'
glance(x, ...)
# S3 method for class 'hf_model'
outliers(object, ...)
# S3 method for class 'hf_model'
report(object, ...)
# S3 method for class 'hf_model'
forecast(object, new_data = NULL, specials = NULL, ...)
# S3 method for class 'hf_model'
backcast(object, h, ...)Arguments
- object, x
A
hf_model(usually accessed through a mable).- ...
Unused.
- type
Type of residuals:
"innovation"(residuals of the airline model, on the transformed scale) or"response"(y - fitted).- new_data
A tsibble with the future dates (and the values of the user-defined regressors, if any).
- specials
Specials evaluated on
new_data(passed by fabletools).- h
Number of periods to backcast.
Value
components(): adablewith the response and the columnstrend, one seasonal column per periodicity (seasonal, orseasonal_week,seasonal_year...),calendar(when holidays or calendar regressors are used),irregularandseason_adjust. The effects of the pre-adjustment are allocated as described in hf_specials.forecast()andbackcast()(only forAIRLINE_DECOMPOSITION()): point forecasts as degenerate distributions (rjd3highfreq does not provide their standard errors yet). The forecasts of the linearized series given by the airline model are combined with the regression effects (holidays, user-defined regressors fromnew_data, level shifts).fitted(),residuals(): from the airline model (the pre-adjustment model, or the airline model ofAIRLINE_DECOMPOSITION()); missing values for the STL/X-11 models without pre-adjustment.tidy(): the parameters of the airline model and the regression coefficients, with their standard errors.glance(): a one-row tibble with the likelihood statistics.outliers(): the rows of the data with an outlier detected by the pre-adjustment.report(): invisibly, the model.
Examples
births <- tsibble::as_tsibble(
tail(rjd3toolkit::Births, 365 * 4),
index = date
)
mb <- model(
births,
airline = AIRLINE_DECOMPOSITION(births ~ period(7) + preadjust(), log = TRUE)
)
components(mb)
#> # A dable: 1,460 x 7 [1D]
#> # Key: .model [1]
#> # : births = trend * seasonal * irregular
#> .model date births trend seasonal irregular season_adjust
#> <chr> <date> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 airline 2021-01-02 1439 1669. 0.905 0.952 1589.
#> 2 airline 2021-01-03 1427 1672. 0.871 0.980 1639.
#> 3 airline 2021-01-04 1824 1675. 1.01 1.08 1806.
#> 4 airline 2021-01-05 1878 1675. 1.07 1.05 1761.
#> 5 airline 2021-01-06 1820 1673. 1.05 1.03 1727.
#> 6 airline 2021-01-07 1762 1669. 1.05 1.00 1676.
#> 7 airline 2021-01-08 1716 1665. 1.06 0.969 1614.
#> 8 airline 2021-01-09 1434 1662. 0.905 0.953 1584.
#> 9 airline 2021-01-10 1416 1662. 0.871 0.979 1627.
#> 10 airline 2021-01-11 1693 1662. 1.01 1.01 1676.
#> # ℹ 1,450 more rows
tidy(mb)
#> # A tibble: 5 × 6
#> .model term estimate std.error statistic p.value
#> <chr> <chr> <dbl> <dbl> <dbl> <dbl>
#> 1 airline theta 0.836 0.0151 55.5 0
#> 2 airline btheta(7) 0.983 0.00801 123. 0
#> 3 airline AO (2023-12-25) -0.274 0.0356 -7.71 1.30e-14
#> 4 airline AO (2024-01-01) -0.221 0.0356 -6.22 4.97e-10
#> 5 airline AO (2024-12-25) -0.222 0.0359 -6.19 5.93e-10
glance(mb)
#> # A tibble: 1 × 8
#> .model nobs nparams log_lik AIC AICc BIC nout
#> <chr> <int> <int> <dbl> <dbl> <dbl> <dbl> <int>
#> 1 airline 1460 6 2707. -5402. -5402. -5370. 3
report(mb)
#> Series: births
#> Model: Airline(7) + preadj.
#> Method: Airline, periodicities: 7
#> Decomposition: multiplicative
#> Pre-adjustment: 0 regressor(s), 3 outlier(s)
#>
#> Coefficients:
#> Estimate Std. Error z value Pr(>|z|)
#> theta 0.8362346 0.0150538 55.5499 < 2.2e-16 ***
#> btheta(7) 0.9831105 0.0080147 122.6631 < 2.2e-16 ***
#> AO (2023-12-25) -0.2741078 0.0355699 -7.7062 1.296e-14 ***
#> AO (2024-01-01) -0.2212515 0.0355707 -6.2201 4.970e-10 ***
#> AO (2024-12-25) -0.2220331 0.0358566 -6.1923 5.931e-10 ***
#>
#> log likelihood = 2706.96, AIC = -5401.93, AICc = -5401.87, BIC = -5370.24
forecast(mb, h = 28)
#> # A fable: 28 x 4 [1D]
#> # Key: .model [1]
#> .model date births .mean
#> <chr> <date> <dist> <dbl>
#> 1 airline 2025-01-01 1754.786 1755.
#> 2 airline 2025-01-02 1757.829 1758.
#> 3 airline 2025-01-03 1768.331 1768.
#> 4 airline 2025-01-04 1517.987 1518.
#> 5 airline 2025-01-05 1443.157 1443.
#> 6 airline 2025-01-06 1663.118 1663.
#> 7 airline 2025-01-07 1765.721 1766.
#> 8 airline 2025-01-08 1753.497 1753.
#> 9 airline 2025-01-09 1756.539 1757.
#> 10 airline 2025-01-10 1767.032 1767.
#> # ℹ 18 more rows
backcast(mb, h = 7)
#> # A tibble: 7 × 3
#> .model date dist
#> <chr> <date> <dist>
#> 1 airline 2020-12-26 1508.095
#> 2 airline 2020-12-27 1450.5
#> 3 airline 2020-12-28 1683.506
#> 4 airline 2020-12-29 1777.721
#> 5 airline 2020-12-30 1757.312
#> 6 airline 2020-12-31 1753.46
#> 7 airline 2021-01-01 1773.476