pmdarima.arima.decompose

pmdarima.arima.decompose(x, type_, m, filter_=None)[source][source]

Decompose the time series into trend, seasonal, and random components.

Parameters:

x : np.array, shape=(n_samples,)

The time series of which the trend, seasonal, and noise/random components will be extracted.

type_: str

The type of decomposition that will be performed - ‘multiplicative’ or ‘additive’. We would use ‘multiplicative’ generally when we see an increasing trend. We use ‘additive’ when the trend is relatively stable over time.

m: int

The frequency in terms of number of observations. This behaves similarly to R’s frequency for a time series (ts).

filter_: np.array, optional (default=None)

A filter by which the convolution will be performed.

Returns:

decomposed_tuple : namedtuple

A named tuple with x, trend, seasonal, and random components where x is the input signal, trend is the overall trend, seasonal is the seasonal component, and random is the noisy component. The input signal x can be mostly reconstructed by the other three components with a number of points missing equal to m.

Notes

This function is generally used in conjunction with pmdarima.utils.visualization.decomposed_plot(), which plots the decomposed components. Also there is an example script in the examples folder of the repo and the Examples section of the docs as well.

References

[R71]Example of decompose using both multiplicative and additive types: https://anomaly.io/seasonal-trend-decomposition-in-r/index.html
[R72]R documentation for decompose: https://www.rdocumentation.org/packages/stats/versions/3.6.1/topics/decompose