Overview
The Hodrick Prescott filter is a filter that was originally designed for use in economic time series. In particular, it was used to smooth out cyclical fluctuations in order to isolate the underlying trend.Algorithm
The algorithm takes a time series {% y_t %} and tries to calculate a trend component {% \tau_t %} such that the following is minimized:
{% min_{\tau} (\sum_{t=1}^T (y_t - \tau_t)^2 + \lambda\sum_{t=2}^{T-1}[(\tau_{t+1} - \tau_t) - (\tau_t - \tau_{t-1})]^2 ) %}