Hodrick-Prescott filter for trend and cyclical components
T = hpfilter(...)
[T,C] = hpfilter(...)
hpfilter(S) uses a Hodrick-Prescott
filter and a default smoothing parameter of 1600 to separate the columns
S into trend and cyclical components.
an m-by-n matrix with m samples
from n time series. A plot displays each time series
together with its trend (the time series with the cyclic component
the smoothing parameter
smoothing to the columns
smoothing is a scalar,
it to all columns. If
S has n columns
smoothing is a conformable vector (n-by-1
the vector components of
smoothing to the corresponding
If the smoothing parameter is
0, no smoothing
takes place. As the smoothing parameter increases in value, the smoothed
series becomes more linear. A smoothing parameter of
a linear trend component.
Appropriate values of the smoothing parameter depend upon the periodicity of the data. The following reference suggests the following values:
Yearly — 100
Quarterly — 1600
Monthly — 14400
T = hpfilter(...) returns the
trend components of the columns of
[T,C] = hpfilter(...) returns
the cyclical components of the columns of
Plot the cyclical component of the U.S. post-WWII seasonally-adjusted real GNP. In
hpfilter, specify that
smoothing is 1600, which is appropriate for quarterly data.
load Data_GNP gnpDate = dates; realgnp = DataTable.GNPR; [~,c] = hpfilter(realgnp,1600); plot(gnpDate,c) axis tight
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).
 Hodrick, Robert J, 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.