MATLAB中有hpfilter函数(或者在MATLAB的帮助文档内搜索Hodrick)
Syntax
hpfilter(S)
hpfilter(S,smoothing)
T = hpfilter(...)
[T,C] = hpfilter(...)
Description
hpfilter(S) uses a Hodrick-Prescott filter and a default smoothing parameter of 1600 to separate the columns of S into trend and cyclical components. S is 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 removed).
hpfilter(S,smoothing) applies the smoothing parameter smoothing to the columns of S. If smoothing is a scalar, hpfilter applies it to all columns. If S has n columns and smoothing is a conformable vector (n-by-1 or 1-by-n), hpfilter applies the vector components of smoothing to the corresponding columns of S.
If the smoothing parameter is 0, no smoothing takes place. As the smoothing parameter increases in value, the