Filters
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 (
The idea behind the HP filter is to draw a smooth line through the series, the trend. Then, the difference between the estimated smooth line and the actual data will give us the cyclical component. The HP filter is derived from the following minimization problem:
We will not go into the details of the minimization problem, but let’s focus on the intuition for a moment. The goal of the problem is to minimize the difference between the actual series,