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