Wednesday, August 17, 2016

Illicit use of the Hodrick-Prescott?

The Hodrick and Prescott (1980, 1997) filter (hereafter, the HP filter) has become a standard method for removing trend movements in the business cycle literature.

I'm reading Notes on Adjusting the Hodrick-Prescott Filter for the Frequency of Observations, a short PDF by Morten O. Ravn and Harald Uhlig. The paper is © 2002 by the President and Fellows of Harvard College and the Massachusetts Institute of Technology, so they're probably right.

Most applications of this filter have been to quarterly data, but data is often available only at the annual frequency, whereas in other cases monthly data might be published. This raises the question of how one can adjust the HP filter to the frequency of the observations so that the main properties of the results are conserved across alternative sampling frequencies.

Their topic is tweaking the HP calculation to allow for different data frequencies.

I use Kurt Annen's VBA code in Excel to do the HP calculation. The code creates a function named HP( ) that does all the work. All you have to give it is the range of source data and a constant.

The constant is how you allow for different data frequencies. Changing the constant changes the amount of "smoothing" you get when you graph the results. The trick is to use the right value for the constant.

I've always used the values 100 for annual data, 1600 for quarterly data, and 14400 for monthly data. Something I picked up from the EViews User Forum a while back. I have some old notes on it.

I shouldn't say I always use those values. I always start with those values. Sometimes I change them. For examples of how changing the value of the smoothing constant affects the results, see this old post.

In this recent post I show why, for one graph of monthly data, I abandoned my usual monthly constant of 14400 in favor of my default annual value 100. The larger value smoothed all the information out of the result -- like Kruger smoothing the head off a statue on Seinfeld.

For quarterly data, Ravn and Uhlig say, the value 1600 is commonly used. (It seems 1600 is the value Mr. Hodrick and Mr. Prescott used in the article that introduced the HP filter.) But for annual data Ravn and Uhlig note four different values: 100, 400, 10, and their own personal favorite, 6.25:
We then show that our recommendations work extremely well on U.S. GDP data: using a value of the smoothing parameter of 6.25 for annual data and 1600 for quarterly data produces almost exactly the same trend. This leads us to reconsider the business cycle “facts” reported in earlier studies. As an example, we cast doubt on a finding by Backus and Kehoe (1992) ...

Using a constant of 6.25 rather than 100 for annual data, the authors produce "almost exactly the same trend" that they get for quarterly data with a constant of 1600. Sounds good. But let me ask: Do you really want to get the same HP trend for the two series on this graph?

Graph #1: Quarterly (blue) and Annual (red) RGDP
I don't think so. The quarterly trend should show more detail.

Maybe if I'm looking at 50 years of data I'd want to think of "the" trend for the data, and it should be the same for both annual and quarterly. But if I'm focused on only a few years of data, it's probably because I'm looking for more subtle differences and I'd want to see more wiggle in the trend for the more wiggly line. I'm not looking at the 50-year trend. I'm looking at what's happened since the crisis.

Sometimes there's good reason to want the same trend from data with different frequencies. But sometimes there's good reason to want different trends.

Here are the two graphs from my "recent" post linked above, and my thoughts at the time:
Today I want to look at the monthly GDP data from Macroeconomic Advisers. I have their data thru May now:

Graph #2: Monthly RGDP since Jan 2009 with an Unresponsive H-P Constant
The blue line shows RGDP growth from 12 months prior. The red line is the Hodrick-Prescott using the constant I'd normally use for monthly data. I think this constant makes the red line a little too unresponsive, there being only about seven years of data.

Here is the same graph with a more responsive Hodrick-Prescott:

Graph #3: Monthly RGDP since Jan 2009 using a More Responsive H-P Constant
Now the red line follows the blue more closely. It helps us see the up-and-down pattern in the jiggy blue data. We are at a low spot now, and evidently RGDP growth has been trending down since the end of 2014.

Graph #2 shows a trend that is essentially flat. Graph #3 shows that RGDP growth has been trending down for a year and a half. Graph #3 is much more informative, and its trend line clearly does a better job of showing the path of RGDP than does Graph #2. But the thing of it is, Graph #3 uses the "wrong" smoothing constant. It uses my default annual value on monthly data!

I chose the annual value on purpose, because I wanted about as much smoothing on the monthly data as I normally get on annual data. It worked.

PS: I went out of my way to find monthly data for Graphs #2 and #3. Monthly, because it shows more variation. It would make no sense to smooth the monthly trend down till it showed as little variation as the annual!


Oilfield Trash said...


The creators of the HP Filter (Hodrick and Prescott) say when you use their filter on Qtr data the smoothing parameter should be 1600.

The first term of the HP algorithm is the sum of the squared deviations from the trend and the second term, which is the sum of squared second differences in the trend, is a penalty for changes in the trend’s growth rate. The larger the value of the positive parameter λ,(constant) the greater the penalty and the smoother the resulting trend will be.

When you use 25 on QTR data and not 1600 you are distorting the estimated trend output of the algorithm.

You have to be very carful when changing the smoothing parameter (especially when it cuts against what is accepted) does not turn into a data fitting exercise

Oilfield Trash said...


One other thing. I am assuming you are using the HP Filter for its intended use.

Hodrick-Prescott filter is a model-free based approach to decomposing a time t series into its trend and cyclical components. Where the cyclical component is the difference between the original series and its trend.