
The Hodrick Prescott filter (HP filter), introduced by Hodrick and Prescott (1980), is a flexible detrending method that
is widely used in empirical macro research. Let's suppose
that the original series
is composed of a trend component
and a cyclical component
![]()
![]()
The HP-Filter isolates the cycle component by following minimization problem.
![]()
The first term is a measure of the fitness of the time
series while the second term is a measure of the smoothness. There
is a conflict between "goodness of fit" and "smoothness".
To keep track of this problem there is a "trade-off"-parameter
.Note that
is 0, the trend component
becomes equivalent to the original series while
diverges to infinity, the trend
component approaches a linear trend.
As you can see the HP filter acts to remove a trend from the data by solving a least square problem. In matrix notation we get
![]()
with
,
and

It can be shown that the solution of the minimization
problem is be given by
where
is the identity matrix with dimension T.
The height of the value
depends on the frequency of the
data. In the literature the following values are suggested.
| 100 |
yearly data |
| 1600 |
quarterly data |
| 14400 |
monthly data |
[notes]
The solution of the HP-filter must satisfies
![]()
The computation could be done by a
native Gauss algorithm. Unfortunately this method is not very efficient
especially if you want detrend a lot of data points. Note, that the
computational complexity of Gaussian elimination is
. A precise look at the matrix
shows
that this matrix has got a pentadiagonal structure. If we use this
property, we can accelerate the calculations strongly.
In the HP-filter Add-In I used an algorithm which is described in Späth, Helmuth "Numerik: Eine Einführung für Mathematiker und Informatiker". Vieweg-Verlag Braunschweig/Wiesbaden (1994)
[related links]
All links will be open in a new window
wikipedia A description of the Hodrick Prescott filter at wikipedia. (HTML)
Hodrick Prescott reference, by Hyeongwoo Kim. A brief introduction. (PDF)
Hodrick Prescott Filter, by Yossi Yakhin. A brief introduction. (PDF)
Links to other sites from these pages are for information only and Kurt Annen accepts no responsibility or liability for access to, or the material on, any site which is linked from or to this site.
screenshot of hp-filter add-in
[download]
for downloading click on the filename
| File: hpfilter.zip Filesize: 131 kb |
The Hodrick Prescott Filter Add-In was written by Kurt Annen. This program is freeware. But I would highly appreciate if you could give me credit for my work by providing me with information about possible open positions as an economist. My focus as an economist is on econometrics and dynamic macroeconomics. If you like the program, please send me an email or donate it.
