DecompositionFilterResult._penalized_result#
- classmethod DecompositionFilterResult._penalized_result(panel, penalty, order, method)[source]#
Run the penalized smoother and package it.
Solves \((I + \lambda D'D)\tau = y\) column by column, records the cutoff period \(\pi / \arcsin(\lambda^{-1/2n} / 2)\), and flags the first and last \(\lceil \text{cutoff} \rceil\) rows (capped at half the sample) as provisional. Shared by
HodrickPrescottFilterandButterworthFilter, which differ only in how they arrive atpenaltyandorder.- Parameters:
- Return type:
- Returns:
The
DecompositionFilterResultwith every row kept.
Example
>>> t = np.arange(60.0)[:, None] >>> res = DecompositionFilterResult._penalized_result( ... 2.0 + 0.5 * t, 1600.0, 2, "hodrick-prescott" ... ) >>> bool(np.abs(res.cycle).max() < 1e-8), round(res.cutoff, 1) (True, 39.7) >>> int(res.provisional.sum()), bool(res.provisional.all()) (60, True)