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

  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.