Decompose a time series into seasonal, trend and remainder components. Seasonal components are estimated iteratively using STL. Multiple seasonal periods are allowed. The trend component is computed for the last iteration of STL. Non-seasonal time series are decomposed into trend and remainder only. In this case, supsmu is used to estimate the trend. Optionally, the time series may be Box-Cox transformed before decomposition. Unlike stl, mstl is completely automated.

STL(formula, iterations = 2, ...)

## Arguments

formula Decomposition specification (see "Specials" section). Number of iterations to use to refine the seasonal component. Other arguments passed to stats::stl().

## Value

A fabletools::dable() containing the decomposed trend, seasonality and remainder from the STL decomposition.

## Specials

### trend

The trend special is used to specify the trend extraction parameters.

trend(window, degree, jump)

 window The span (in lags) of the loess window, which should be odd. If NULL, the default, nextodd(ceiling((1.5*period) / (1-(1.5/s.window)))), is taken. degree The degree of locally-fitted polynomial. Should be zero or one. jump Integers at least one to increase speed of the respective smoother. Linear interpolation happens between every jumpth value.

### season

The season special is used to specify the season extraction parameters.

season(period = NULL, window = NULL, degree, jump)

 period The periodic nature of the seasonality. This can be either a number indicating the number of observations in each seasonal period, or text to indicate the duration of the seasonal window (for example, annual seasonality would be "1 year"). window The span (in lags) of the loess window, which should be odd. If the window is set to "periodic" or Inf, the seasonal pattern will be fixed. The window size should be odd and at least 7, according to Cleveland et al. The default (NULL) will choose an appropriate default, for a dataset with one seasonal pattern this would be 11, the second larger seasonal window would be 15, then 19, 23, ... onwards. degree The degree of locally-fitted polynomial. Should be zero or one. jump Integers at least one to increase speed of the respective smoother. Linear interpolation happens between every jumpth value.

### lowpass

The lowpass special is used to specify the low-pass filter parameters.

lowpass(window, degree, jump)

 window The span (in lags) of the loess window of the low-pass filter used for each subseries. Defaults to the smallest odd integer greater than or equal to the seasonal period which is recommended since it prevents competition between the trend and seasonal components. If not an odd integer its given value is increased to the next odd one. degree The degree of locally-fitted polynomial. Must be zero or one. jump Integers at least one to increase speed of the respective smoother. Linear interpolation happens between every jumpth value.

## References

R. B. Cleveland, W. S. Cleveland, J.E. McRae, and I. Terpenning (1990) STL: A Seasonal-Trend Decomposition Procedure Based on Loess. Journal of Official Statistics, 6, 3–73.

stl, supsmu

## Examples

as_tsibble(USAccDeaths) %>%
model(STL(value ~ trend(window = 10))) %>%
components()#> # A dable: 72 x 7 [1M]
#> # Key:     .model [1]
#> # :        value = trend + season_year + remainder
#>    .model                  index value trend season_year remainder season_adjust
#>    <chr>                   <mth> <dbl> <dbl>       <dbl>     <dbl>         <dbl>
#>  1 STL(value ~ trend(w… 1973 Jan  9007 9676.       -792.     123.          9799.
#>  2 STL(value ~ trend(w… 1973 Feb  8106 9691.      -1510.     -75.1         9616.
#>  3 STL(value ~ trend(w… 1973 Mar  8928 9706.       -707.     -70.7         9635.
#>  4 STL(value ~ trend(w… 1973 Apr  9137 9720.       -522.     -61.2         9659.
#>  5 STL(value ~ trend(w… 1973 May 10017 9733.        325.     -41.3         9692.
#>  6 STL(value ~ trend(w… 1973 Jun 10826 9753.        843.     229.          9983.
#>  7 STL(value ~ trend(w… 1973 Jul 11317 9764.       1617.     -64.5         9700.
#>  8 STL(value ~ trend(w… 1973 Aug 10744 9734.        981.      28.4         9763.
#>  9 STL(value ~ trend(w… 1973 Sep  9713 9638.       -105.     181.          9818.
#> 10 STL(value ~ trend(w… 1973 Oct  9938 9473.        232.     233.          9706.
#> # … with 62 more rows