msdecompose function

Multiple seasonal classical decomposition

Multiple seasonal classical decomposition

Function decomposes multiple seasonal time series into components using the principles of classical decomposition.

msdecompose(y, lags = c(12), type = c("additive", "multiplicative"), smoother = c("ma", "lowess", "supsmu"), ...)

Arguments

  • y: Vector or ts object, containing data needed to be smoothed.
  • lags: Vector of lags, corresponding to the frequencies in the data.
  • type: The type of decomposition. If "multiplicative" is selected, then the logarithm of data is taken prior to the decomposition.
  • smoother: The type of function used in the smoother of the data to extract the trend and in seasonality smoothing. smoother="ma" relies on the centred moving average and will result in the classical decomposition. smoother="lowess" will use lowess , resulting in a decomposition similar to the STL (stl ). Finally, smoother="supsmu" will use the Friedman's super smoother via supsmu .
  • ...: Other parameters passed to smoothers. Only works with lowess/supsmu.

Returns

The object of the class "msdecompose" is return, containing:

  • y - the original time series.
  • initial - the estimates of the initial level and trend.
  • trend - the long term trend in the data.
  • seasonal - the list of seasonal parameters.
  • lags - the provided lags.
  • type - the selected type of the decomposition.
  • yName - the name of the provided data.

Details

The function applies centred moving averages based on filter

function and order specified in lags variable in order to smooth the original series and obtain level, trend and seasonal components of the series.

Examples

# Decomposition of multiple frequency data ## Not run: ourModel <- msdecompose(forecast::taylor, lags=c(48,336), type="m") ourModel <- msdecompose(AirPassengers, lags=c(12), type="m") plot(ourModel) plot(forecast(ourModel, model="AAN", h=12))

References

  • Svetunkov I. (2023) Smooth forecasting with the smooth package in R. arXiv:2301.01790. tools:::Rd_expr_doi("10.48550/arXiv.2301.01790") .
  • Svetunkov I. (2015 - Inf) "smooth" package for R - series of posts about the underlying models and how to use them: https://openforecast.org/category/r-en/smooth/.

See Also

filter

Author(s)

Ivan Svetunkov, ivan@svetunkov.com

  • Maintainer: Ivan Svetunkov
  • License: LGPL-2.1
  • Last published: 2025-04-02