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
, andrandom
components wherex
is the input signal,trend
is the overall trend,seasonal
is the seasonal component, and random is the noisy component. The input signalx
can be mostly reconstructed by the other three components with a number of points missing equal tom
.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 theexamples
folder of the repo and theExamples
section of the docs as well.References
[R68] Example of decompose using both multiplicative and additive types: https://anomaly.io/seasonal-trend-decomposition-in-r/index.html [R69] R documentation for decompose: https://www.rdocumentation.org/packages/stats/versions/3.6.1/topics/decompose