Detrending filters

Hi Johannes,

I was closely following your guide for Observation equations while estimating my model. Because my model does not consider any specific trend, while taking data to the log-linearized model, I simply used one-sided HP filter to remove trend from Log(variables). Also this makes the series mean zero. Can I use first difference also in this case, if this produce series that have mean approximately zero?

Recently I was criticised for using this HP-filter to de-trend my data that, ‘this assumption is non-standard and HP filter may introduce a ‘phase shift’ in the filtered variables’. I don’t really understand what does this ‘phase shift’ mean. First difference (as in Justiniano et al 2011) or trend technology ( as in Ireland, JMCB 2012) are suggested as alternatives. From Remark 12 in your guide, I understand why we should use one sided-HP filter. I would be happy to hear your insights on this.
Many thanks.

Regarding the one-sided HP-filter: Something being non-standard does not mean it is not OK. There are quite a few papers that use a one-sided HP-filter. But the point about the “phase shift” is right, but not helpful, because it applies to pretty much all one-sided (causal) filters.

The regular HP-filter is a two sided filter because it essentially filters the data series with the one-sided HP-filter twice: once forward and once backward. The one-sided HP filter introduces a phase shift and by filtering the series again in the opposite direction the phase is shifted back to normal.

Now you could use first differences if you adjust the observation equation accordingly (demeaned first differences in your case). This is a lot more standard, but first differences also introduce a phase shift, see the Appendix to And I have never seen anyone complain about phase shifts introduced by first differences.

Thanks Johannes. I want to use first difference to see what changes it produces and compare with the results under hp-filter data. Just to confirm whether I am writing observation equations correctly:

Y_obs = Y_t -Y_t-1 where Y_t is log-linearised model variable when no specific trend is assumed in the model.

This time Y_obs is constructed as follows:
Y_obs =100* ∆LN (GDP percapita_t)]= 100*[LN(GDP percapita_t)- LN(GDP percapita_t-1)]

Do I need to subtract the mean of the first difference from the first difference to ensure it is mean zero? The mu term in the RHS is zero as no trend is assumed. From Listing 11, do I need to take first difference for inflation and interest rate in similar way?

Yes, that is correct. You have to subtract the mean from the first difference. For inflation and interest rates one typically does not use first differences, because they are supposed to be already stationary.


Could you please cite those papers that use one-sided HP-filter? Are there papers that use the regular HP-filter?


Thanks Johannes. And thanks to JoseDNino for asking this. Johannes, could you please give us such references for DSGE model estimation? I have looked at the Stock and Watson (1999, JME) paper that used one-sided hp-filter to detrend data while forecasting inflation based on the Phillips curve.

Another issue, if we use linear detrend method to remove trend from stationary (inflation in Log) and non-stationary (GDP in Log) variables, the observation equation should be the same as one-sided hp-filter case? I guess linear detrending does not produce mean zero series. In that case we need to de-mean the filtered series before taking them to model.

@sadia: linear filtering typically means regressing on a constant and a trend. The constant will take out the mean. If you do not use a constant, you also need to demean.

Note that the Stock-Watson argument applies to DSGE models as well. Their solution takes the form of a VARMA-process and the likelihood minimizes the forecast error.

Two papers using the one-sided HP-filter in the context of DSGE model estimation are

  • Mingming Jiang (2016): “By force of demand: Explaining cyclical fluctuations of international trade and government spending”, JEDC, Volume 69,p. 249–267
  • Born/Pfeifer (2014): “Policy risk and the business cycle”, JME, 68,p. 68-85

@JoseDNino: yes, there are papers using the regular HP-filter. Christensen/Dib (2008): The financial accelerator in an estimated New Keynesian model, RED is one example. But nowadays this is really frowned upon.

Great help, as usual.
Thanks a lot.


with respect to that topic, I am wondering whether the 1-sided hp filter is also better than the regular hp-filter for comparing empirical moments and model-generated moments in a calibrated DSGE model, as opposed to an estimated model ?

Thanks a lot

In that case it does not really matter, because both the model and the actual data are treated by the same filter before comparing them. The profession thinks to agree that the two-sided HP is well able to isolate business cycle frequencies (probably better than the one-sided version). However, the two-sided version cannot be used together with a recursive backward-looking state-space model, which is why you cannot use it for estimation.

Hi Johannes,

As I said I am re-estimating my model with first difference data to compare with that of HP-filter, I got a labor parameter estimate negative if I enter the hours worked data in log level directly. However, if I enter this series in growth form: N_obs = ln(N) - ln(N(-1))= N_model, then parameters estimates become sensible, similar to the hp-filter case. The N is ((Total quarterly work hour index/100)/CNIP). I guess I can assume here that hours worked per person is not stationary at level? Overall, (based on my model) the model generated standard deviations of the variables are higher than in the HP-filter case when I compare them to s.d of the actual data.
Another point is I demeaned only Y,C,I variables, not the rates variables (in rates, not growth) and not the hours worked. It would be great if you give me some comments. Thanks

What you need to compare is growth rates in that data compare to growth rates in the model. For the HP-filter, the comparison would be different. There is no straightforward comparison between the HP-filter and the first difference filter. You can compare the volatility of growth rates to the one of the HP-filtered variables, but there you are looking at different frequency bands.

Hours per capital should be stationary, however there are long-run movements in labor supply that may be hard to capture by the model that the HP-filter takes out. Therefore some people argue you should also take first differences of the labor series. But this is a matter of taste.

Regarding the means: you need to make sure that the data objects and the model objects are consistent. If your model objects are mean 0, your data also needs to be mean 0. So if hours or inflation rates are mean 0, you need to demean the data as well.

You are absolutely right. I forgot that now my actual data is in growth format. I understand I have to compare the std of model generated series to the std of the growth data.

After de-meaning the rest of the variables (inflation, interest rate, hours and spread), the parameter estimates are sensible and very much consistent with the earlier estimates with the hp-filter data. That means may be the non-zero mean of hours data and other variables were producing non-plausible results.

I have a question regarding identification. Perhaps I should post separately. I tried to read the the Canova’s paper on identification and Ratto and Iskrev’s paper on dynare’s identification routine. Unfortunately, I failed to understand clearly the economics of identification and too much technical things there. In my model, the dynare’s identification test shows that all model parameters are identified. Say, I have two shocks that belong to the financial category. I would like to understand which observable variable/s is helping me to distinguish between these two shocks. I used variables of national income accounts, one labor market, two financial sectors. Any clue on which way should I start thinking on or from those two papers? Thanks.

Yes, please start a new topic.