hpfilter
Hodrick-Prescott filter for trend and cyclical components
Syntax
Description
Separate one or more time series into trend and cyclical components by applying
the Hodrick-Prescott filter [1]. hpfilter
optionally plots the series and
trend component, with cycles removed. The plot helps you select a smoothing
parameter.
[
returns the trend Trend
,Cyclical
] = hpfilter(Y
)Trend
and cyclical Cycilcal
components from applying the Hodrick-Prescott Filter to each variable (column) of the
input matrix of time series data Y
. The smoothing parameter default
is 1600
, suggested in [1] for quarterly
data.
[
returns the tables or timetables TTbl
,CTbl
] = hpfilter(Tbl
)TTbl
and CTbl
containing variables for the trend and cyclical components, respectively, from applying
the Hodrick-Prescott Filter to each variable in the input
table or timetable Tbl
. To select different variables in
Tbl
to filter, use the DataVariables
name-value argument.
[___] = hpfilter(___,
specifies options using one or more name-value arguments in
addition to any of the input argument combinations in previous syntaxes.
Name=Value
)hpfilter
returns the output argument combination for the
corresponding input arguments. For example,
hpfilter(Tbl,Smoothing=100,DataVariables=1:5)
applies the
Hodrick-Prescott filter to the first five variables in the input table
Tbl
and sets the smoothing parameter to
100
.
hpfilter(___)
plots time series variables in the
input data and their respective trend components, computed by the Hodrick-Prescott filter,
on the same axes.
hpfilter(
plots on the axes specified by ax
,___)ax
instead
of the current axes (gca
). ax
can precede any of the input
argument combinations in the previous syntaxes.
Examples
Input Arguments
Output Arguments
More About
Tips
For high-frequency series, the Hodrick-Prescott filter can produce anomalous endpoint effects. In this case, do not extrapolate the series using the results of the filter.
References
[1] Hodrick, Robert J., and Edward C. Prescott. "Postwar U.S. Business Cycles: An Empirical Investigation." Journal of Money, Credit and Banking 29, no. 1 (February 1997): 1–16. https://doi.org/10.2307/2953682.