BeveridgeNelsonDecomposition.compute#
- BeveridgeNelsonDecomposition.compute()[source]#
Decompose the levels.
Demeans the first differences by the fitted drift (zero under trend
"n"), evaluates the forecast sum \(e_1' F (I - F)^{-1} x_t\) from the ARMA parameters and residuals, and adds it to the level to form the trend.- Return type:
- Returns:
The
DecompositionFilterResult, one row shorter than the series (the first difference has no value att = 0), withorderset to the ARMA(p, q)and no row provisional.- Raises:
NumericalError – If the differenced series has a unit root, which makes \(I - F\) singular and the trend undefined.
Example
>>> from cultivars.univariate.box_jenkins import ARIMA >>> rng = np.random.default_rng(0) >>> y = np.cumsum(0.2 + rng.standard_normal(300)) >>> res = BeveridgeNelsonDecomposition(ARIMA(y, order=(0, 1, 1)).fit()).compute() >>> res.method, res.order, bool(res.provisional.any()) ('beveridge-nelson', (0, 1), False) >>> bool(np.allclose(res.trend + res.cycle, y[1:, None])) True
A pure random walk has no forecastable momentum, hence no cycle:
>>> walk = BeveridgeNelsonDecomposition(ARIMA(y, order=(0, 1, 0)).fit()).compute() >>> float(np.abs(walk.cycle).max()) 0.0