One side HP-filter and model fit to real data

Dear professor jpfeifer,

I got three questions on one side HP-filter and model fit to real data:

First, when doing Bayesian estimation, the real data (e.g. real output “y”) are first seasonally adjust, then take the log of the data and apply the one-sided HP-filter. My question is we can not use the one-sided HP-filter in Eviews as it is two-sided HP-filter, it must be done in Matlab, right? Can you give me an example code for one-side HP-filter of Matlab?

Second, if variable of the code is written in level, the observation is then : yobs=log(y)-log(steadystate y), where yobs is oberved variable (the data after first seasonally adjust, take log, one-sided HP-filter), is this right?

Third, when judging whether the estimation result fit the real data well, as the variable of the code is in level, I add log_y in “Definition of variables” , use the code "stoch_simul(order=1,hp_filter=1600); log_y ", then compare the theoritical moments (S.D or Correlations) with the statistics of the real data, is this right?

Really hope for your reply which always help me a lot, thank you, professor.

1 Like
  1. Yes, you cannot use the two-sided filter. Matlab code is available at matlab/one_sided_hp_filter.m · master · Dynare / dynare · GitLab
  2. Yes, that matching is correct for a non-logged and non-demeaned variable.
  3. No, ist should be one_sided_hp_filter=1600 in the stoch_simul-command if you want to compare it to one-sided HP-filtered data.

Thank you, professor, so stoch_simul(order=1,one_sided_hp_filter=1600); log_y " is correct, right?

Dear professor, I am wandering if you can clearly explain to me why variables in log-linearization using hp_filter=1600, while variables in level using one_sided_hp_filter=1600in thestoch_simul` -command? I am really confused about the hp_filter option, always thank you and best wishes.

It’s not about logs vs. levels. Your data and model treatments need to be consistent for meaningful comparisons. You said you used the one-sided HP filter for the data, so you should use it for the model as well.

Dear @jpfeifer in almost similar model to check whether estimation result fit the real data well should I use the code stoch_simul(order=1, one_sided_hp_filter=1600) after the code estimation(order=1,datafile=Data, mode_check … etc) and compare MOMENTS OF SIMULATED VARIABLES with the statistics of the real data?

There are two options:

  1. You opt for full consistency with respect to filtering and compare filtered objects in the model (i.e. using the one_sided_hp_filter-option of stoch_simul) with the filtered objects in the data.
  2. You recognize that you provided filtered data to full information estimation and therefore asked the model in it’s unfiltered version to replicate the stochastic properties of the filtered data. Thus, you would compare unfiltered model variables to the filtered data.

The most common option would the second one.

@jpfeifer Thanks for your comment. I estimated the model and want to test how estimation result fits the real data well. So, for the second option you suggested, how should I code it in Dynare mod?

In that case, simply don’t provide a filter option to stoch_simul.

1 Like

I don’t think the second one @lovefukanglin mentioned could work @jpfeifer , in full information Bayesian estimation. When we conduct the full information Bayeisna estimation, we use Kalman Filter to calculate the likelihood, which is based on the state equations and measurement equations. If you impose HP filter on the data, you actually twist the spectrum and to be comparative we need to impose the same filter on the model.
If you just want to match the moments, it would be fine. However, if you want to use Kalman Filter to calculate the likelihood, it will be wrong because the state equations change, but until now we cannot solve the change analytically (at least for hp filter). So I suspect @lovefukanglin did an incorrect thing in using Bayesian estimation because after HP filter the A and B matrix in section 4.13.3 of Dynare Manuel change. Alternatively, you can use Quasi-Bayesian or limited information likelihood to match the moments yet I do not know if dynare could provide some easy way to conduct these methods.

This is clearly not my preference, but you can estimate your model on HP-filtered data. In that case, you treat your DSGE model as the data generating process of the filtered data. It is not supposed to reproduce the characteristics of the original unfiltered data.

Thanks a lot for replying! I thought we had the same preference and concern for this problem. Unfortunately, except we add the trend part(growth rate) into the DSGE model, the DGP of the model does not share the same economic meaning with the detrended data via the HP filter. The former represents the derivation around a constant steady state yet the latter represents the derivation around a fluctuated trend.

I fully understand that distinction. But there are people that consider the DSGE model estimated on filtered data as the DGP for the business cycle component for the data. There are some frequency components taken out of the data by the filter that are unrelated to the cycle and we may not care about those. From that perspective, you may not care about what the underlying steady state does.