Documentation Center

  • Trial Software
  • Product Updates

Using the Hodrick-Prescott Filter to Reproduce Their Original Result



$$y_{t} = g_{t} + c_{t}$$


The objective function for the Hodrick-Prescott filter has the form

$$\sum_{t = 1}^{T} c_{t}^{2} + \lambda \sum_{t = 2}^{T - 1} ((g_{t + 1} - g_{t}) - (g_{t} - g_{t - 1}))^{2}$$

with a smoothing parameter lambda. The programming problem is to minimize the objective over all g1, ... , gT.


Note that this filter is equivalent to a cubic spline smoother.

Use of the Hodrick-Prescott Filter to Analyze GNP Cyclicality


load Data_GNP

startdate = 1950;	% date range is from 1947.0 to 2005.5 (quarterly)
enddate = 1979.25;	% change these two lines to try alternative periods

startindex = find(dates == startdate);
endindex = find(dates == enddate);

gnpdates = dates(startindex:endindex);
gnpraw = log(Dataset.GNPR(startindex:endindex));

We run the filter for different smoothing parameters lambda = 400, 1600, 6400, and Inf. The infinite smoothing parameter just detrends the data.


Plot Cyclical GNP and Its Relationship with Long-Term Trend


hold all
ylabel('\bfGNP Growth');
legend('Cyclical GNP','Difference');
hold off


Statistical Tests on Cyclical GNP


gnpacf4 = autocorr(gnpcycle4,10);
gnpacf16 = autocorr(gnpcycle16,10);
gnpacf64 = autocorr(gnpcycle64,10);
gnpacfinf = autocorr(gnpcycleinf,10);

WarnState = warning('off','econ:adftest:LeftTailStatTooSmall');

[H4, ~, gnptest4] = adftest(gnpcycle4,'model','ARD');
[H16, ~, gnptest16] = adftest(gnpcycle16,'model','ARD');
[H64, ~, gnptest64] = adftest(gnpcycle64,'model','ARD');
[Hinf, ~, gnptestinf] = adftest(gnpcycleinf,'model','ARD');


fprintf(1,'  Autocorrelations\n');
for i=2:11
Table 1 from Hodrick and Prescott Reference
              Smoothing Parameter
                     400        1600        6400    Infinity
  Std. Dev.         1.52        1.75        2.06        3.11
           1        0.74        0.78        0.82        0.92
           2        0.38        0.47        0.57        0.81
           3        0.05        0.17        0.33        0.70
           4       -0.21       -0.07        0.12        0.59
           5       -0.36       -0.24       -0.03        0.50
           6       -0.39       -0.30       -0.10        0.44
           7       -0.35       -0.31       -0.13        0.39
           8       -0.28       -0.29       -0.15        0.35
           9       -0.22       -0.26       -0.15        0.31
          10       -0.19       -0.25       -0.17        0.26
  Unit Root        -4.35       -4.13       -3.79       -2.28
  Reject H0            1           1           1           0


[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.


Was this topic helpful?