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(.data, formula, iterations = 2, ...)

Arguments

.data

A tsibble.

formula

Decomposition specification (see "Specials" section).

iterations

Number of iterations to use to refine the seasonal component.

...

Other arguments passed to stats::stl().

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 = 13, 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
windowis 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.
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
periodwhich 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.

See also

Examples

USAccDeaths %>% as_tsibble %>% STL(value ~ trend(window = 10))
#> # A dable: 72 x 6 [1M] #> # STL Decomposition: value = trend + season_year + remainder #> index value trend season_year remainder seas_adjust #> <mth> <dbl> <dbl> <dbl> <dbl> <dbl> #> 1 1973 Jan 9007 9678. -788. 118. 9795. #> 2 1973 Feb 8106 9692. -1513. -73.2 9619. #> 3 1973 Mar 8928 9708. -716. -63.4 9644. #> 4 1973 Apr 9137 9721. -521. -63.6 9658. #> 5 1973 May 10017 9734. 328. -44.6 9689. #> 6 1973 Jun 10826 9754. 831. 241. 9995. #> 7 1973 Jul 11317 9764. 1633. -80.6 9684. #> 8 1973 Aug 10744 9734. 974. 35.1 9770. #> 9 1973 Sep 9713 9637. -100. 176. 9813. #> 10 1973 Oct 9938 9472. 227. 240. 9711. #> # … with 62 more rows