# HP Filter with Stationary Models 

**URL:** <https://forum.dynare.org/t/hp-filter-with-stationary-models/27962>\
**Category:** SMM/GMM/IRF-Matching\
**Created:** [7 September 2025 17:46 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962 "2025-09-07T17:46:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sarv1926](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sarv1926](https://forum.dynare.org/u/Sarv1926)\
**Post date:** [7 September 2025 17:46 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962/1 "2025-09-07T17:46:40Z")

</div>

Hello Professor,

I am working with a stationary NK-DSGE model and would like to estimate it using the method\_of\_moments() command in Dynare. My empirical data has been HP-filtered, and I am uncertain about the correct treatment of the model moments in this case.

1. Should the simulated model moments also be HP-filtered before comparison? Some references suggest that HP-filtering can alter the statistical properties of moments even if the model is already stationary, while others do not emphasize this. I would appreciate clarification on what the best practice is.

2. If HP-filtering is indeed required, how can this be implemented with method\_of\_moments(), given that the command does not appear to have a native HP-filter option?

3. Is there a reliable alternative way to handle this case that still provides asymptotic standard errors for parameter estimates, similar to what method\_of\_moments() offers?

Thank you very much for your guidance.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [10 September 2025 11:09 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962/2 "2025-09-10T11:09:52Z")

</div>

1. Yes, the comparison of moments between data and model generally should involve the same filtering. For the opposite perspective, see [One side HP-filter and model fit to real data - #11 by jpfeifer](https://forum.dynare.org/t/one-side-hp-filter-and-model-fit-to-real-data/19956/11)

2. That is not yet possible. We are working on supporting it for SMM. See [Draft: SMM: Enable filtering (!2391) · Merge requests · Dynare / dynare · GitLab](https://git.dynare.org/Dynare/dynare/-/merge_requests/2391)

3. Not yet.

---

<div class="post-metadata">

**Author:** ![Sarv1926](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sarv1926](https://forum.dynare.org/u/Sarv1926)\
**Post date:** [15 September 2025 14:00 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962/3 "2025-09-15T14:00:06Z")

</div>

Thank you so much Professor.

Until the HP filter is natively implemented inside **`method_of_moments()`**, would applying **`sample_hp_filter()`** externally to the simulated series and then using those filtered series as variables in the **`method_of_moments()`** moment-matching procedure be an appropriate approach?

If this is correct, I understand that the HP-filtered cyclical variables would have to be declared as endogenous variables within the model and must hence appear in the model block to avoid errors.

Could you please advise on the best practice for incorporating these HP-filtered variables inside the Dynare model block? Is there a recommended way to define the HP-filtered cyclical components as auxiliary endogenous variables with equations approximating the HP filter within the model?

Thank you again for your time and help.

---

<div class="post-metadata">

**Author:** ![Sarv1926](https://forum.dynare.org/letter_avatar_proxy/v4/letter/s/e19adc/32.png) [@Sarv1926](https://forum.dynare.org/u/Sarv1926)\
**Post date:** [23 September 2025 07:59 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962/5 "2025-09-23T07:59:36Z")

</div>

Dear Professor,

I just wanted to kindly follow up on my earlier question regarding incorporating HP-filtered variables within the `method_of_moments` framework in Dynare. I completely understand you must be very busy, but your guidance on the best practice would be immensely helpful as I move forward with my work.

Thank you again for your time and support.

---

<div class="post-metadata">

**Author:** ![jpfeifer](https://forum.dynare.org/user_avatar/forum.dynare.org/jpfeifer/32/5044_2.png) [@jpfeifer](https://forum.dynare.org/u/jpfeifer)\
**Post date:** [23 September 2025 14:24 UTC](https://forum.dynare.org/t/hp-filter-with-stationary-models/27962/6 "2025-09-23T14:24:14Z")

</div>

1. [SMM: Enable filtering (!2391) · Merge requests · Dynare / dynare · GitLab](https://git.dynare.org/Dynare/dynare/-/merge_requests/2391) is pretty much done and will be merged into the unstable version in the next few days.
2. Passing filtered data to the command is not advocated as you would be matching filtered moments to unfiltered ones within the command.
3. Defining HP-filtered variables within the model does not work. The HP filter is a two-sided filter, i.e., you need to use a smoother to extract HP-filtered data. That cannot be combined with method of moments.
