Define decompositions of high-frequency series (daily, hourly...) to be used
inside fabletools::model():
MSTL(): multiple STL (rjd3highfreq::mstl());ISTL(): iterative STL (rjd3highfreq::istl());STLPLUS(): STL with one periodicity (rjd3highfreq::stlplus());X11PLUS(): extended X-11 with one periodicity (rjd3highfreq::x11plus()).
Usage
MSTL(formula, multiplicative = TRUE, ...)
ISTL(formula, multiplicative = TRUE, ...)
STLPLUS(formula, multiplicative = TRUE, ...)
X11PLUS(formula, multiplicative = TRUE, ...)Arguments
- formula
Model formula: the name of the variable to decompose (
y), ory ~ specials(see hf_specials).- multiplicative
Multiplicative (
TRUE, default) or additive (FALSE) decomposition. With"auto", the choice is made withrjd3highfreq::loglevel().- ...
Other arguments passed to the function of rjd3highfreq (e.g.
swindow,twindow,robustforMSTL();trend_horizon,seas_s0,seas_s1forX11PLUS()).
Value
A model definition that can be passed to fabletools::model(). Once
fitted, the mable column contains a hf_model object. Use
components() to get the decomposition as a dable.
Details
The series can be pre-adjusted (outliers, holidays, user-defined regressors)
with rjd3highfreq::fractional_airline_estimation(): see hf_specials.
With multiplicative = TRUE, the pre-adjustment is done on the log of the
series.
These models have no forecasting method: use fabletools::decomposition_model()
to forecast the components separately, or AIRLINE_DECOMPOSITION().
Examples
births <- tsibble::as_tsibble(
tail(rjd3toolkit::Births, 365 * 4),
index = date
)
mb <- model(
births,
mstl = MSTL(births),
x11 = X11PLUS(births ~ period(7))
)
components(mb)
#> # A dable: 2,920 x 9 [1D]
#> # Key: .model [2]
#> # : births = trend * seasonal_week * seasonal_year * irregular
#> .model date births trend seasonal_week seasonal_year irregular
#> <chr> <date> <int> <dbl> <dbl> <dbl> <dbl>
#> 1 mstl 2021-01-02 1439 1932. 0.847 0.912 0.964
#> 2 mstl 2021-01-03 1427 1932. 0.888 0.956 0.870
#> 3 mstl 2021-01-04 1824 1932. 1.07 0.951 0.931
#> 4 mstl 2021-01-05 1878 1932. 1.10 0.957 0.921
#> 5 mstl 2021-01-06 1820 1932. 1.05 0.959 0.934
#> 6 mstl 2021-01-07 1762 1932. 1.03 0.965 0.913
#> 7 mstl 2021-01-08 1716 1932. 1.01 0.949 0.929
#> 8 mstl 2021-01-09 1434 1932. 0.848 0.977 0.896
#> 9 mstl 2021-01-10 1416 1932. 0.887 0.964 0.857
#> 10 mstl 2021-01-11 1693 1932. 1.06 0.939 0.877
#> # ℹ 2,910 more rows
#> # ℹ 2 more variables: season_adjust <dbl>, seasonal <dbl>
# Pre-adjustment of the outliers before the decomposition (weekly
# periodicity only, to keep the example fast)
mb <- model(
births,
mstl = MSTL(births ~ period(7) + preadjust(outliers = c("ao", "ls")))
)
outliers(mb)
#> # A tsibble: 3 x 3 [1D]
#> # Key: .model [1]
#> .model date births
#> <chr> <date> <int>
#> 1 mstl 2023-12-25 1276
#> 2 mstl 2024-01-01 1347
#> 3 mstl 2024-12-25 1394