hpfilter - Run Hodrick-Prescott filter

Syntax

hpfilter(S)
hpfilter(S,smoothing)
T = hpfilter(...)
[T,C] = hpfilter(...)

Description

Remarks

The Hodrick-Prescott filter separates a time series yt into a trend component Tt and a cyclical component Ct such that yt = Tt + Ct. It is equivalent to a cubic spline smoother, with the smoothed portion in Tt.

The objective function for the filter has the form

where m is the number of samples and λ is the smoothing parameter. The programming problem is to minimize the objective over all T1, ... , Tm. The first sum minimizes the difference between the time series and its trend component (which is its cyclical component). The second sum minimizes the second-order difference of the trend component (which is analogous to minimization of the second derivative of the trend component).

Example

Plot the cyclical component of the U.S. post-WWII seasonally-adjusted real GNP:

load gnp
gnpdate = gnp(:,1);
realgnp = gnp(:,3);
[T,C] = hpfilter(realgnp);
Warning: Missing or empty Smoothing parameter set to 1600.
plot(gnpdate,C)

Reference

[1] Robert J. Hodrick and Edward C. Prescott, "Postwar U.S. Business Cycles: An Empirical Investigation," Journal of Money, Credit, and Banking, Vol. 29, No. 1, February 1997, pp. 1-16.

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS