Learn two techniques to decompose time series, the Hodrick-Prescott filter and the STL decomposition.

Calculating moving averages or using statsmodels’ seasonal_decompose function should be our first approach when exploring the components of our time series. However, these methods often fall short of fully decomposing the data. In this lesson, we’ll learn about two filters that help us better separate the elements of our series: the Hodrick-Prescott Filter and the Seasonal-Trend decomposition using LOESS (STL), where LOESS is the acronym for locally estimated scatterplot smoothing.

The Hodrick-Prescott filter

The Hodrick-Prescott (HP) filter is a filtering method used to separate the trend and the cyclical components of a series (gtg_t and ctc_t, respectively). The filter is not designed to yield a seasonal component. Any seasonality in the data will leak to the trend component. Consequently, the filter is more suitable for nonseasonal series. This is not to say that the series can’t have periodical ups and downs, but that these should be of an irregular duration. This is the case for financial and economic data. Stock prices and countries’ GPD growth rates usually have a clearly defined trend, but this is subject to largely unpredictable fluctuations. This is what we call a business cycle.

Get hands-on with 1200+ tech skills courses.