# HP-filter data and theoretical moments

**URL:** <https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181>\
**Category:** SMM/GMM/IRF-Matching\
**Created:** [26 October 2021 16:19 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181 "2021-10-26T16:19:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![dsge\_modeling](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@dsge\_modeling](https://forum.dynare.org/u/dsge_modeling)\
**Post date:** [26 October 2021 16:19 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/1 "2021-10-26T16:19:01Z")

</div>

I’m calibrating to log-hp filtered second moments. I’m aware that in order for the theoretical moments to be comparable with log-hp filtered data moments, it’s recommendable to also hp filter the (logs) model with `stoch_simul(hp_filter=1600, order=1)`, which compute theoretical hp-filtered following the outline of Uhlig (2001) according to the Dynare manual (4.6).

Now, when performing moment-matching in my model and following the previous process, I think that applying the hp-filter to the model is difficulting the matching of some moments. For instance, my data gdp first-order autocorrelation is about 0.85, when I use a first-guess calibration parameter vector the no-hp filtered theoretical moment for \rho(gdp\_{t},gdp\_{t-1}) is about 0.9, and when I hp-filter the theoretical moment is about 0.7. The thing is that for this second case, when calibrating the model struggles a lot for increasing this autocorrelation to 0.84, where the identified parameter (which is the autocorrelation parameter for TFP ar(1) process) wants to get values too close to a unit-root, which is wrong since my model does not contemplate unit root to TFP shocks.

Also, with other moments the model struggles to get correct or close to correct theoretical moment values. I’d appreciate if you could give me some advice in how to improve my calibration by moment matching. I think I’m close, I’ve tried trying different initial-guess parameter values, also I’ve dropped from calibration some moments that do not improve its distance from the data ones after many iterations.

Some comments would be appreciated. Thanks!

PD: Also I would want to check if this mentioned Uhlig (2001) reference for computing hp-filtered theoretical moments is [this same one](https://papers.ssrn.com/sol3/papers.cfm?abstract_id=273355). Thanks.

---

<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:** [28 October 2021 09:33 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/2 "2021-10-28T09:33:14Z")

</div>

1. Unfortunately, this sounds like your model is incapable of reproducing the data dynamics. Often there is not much you can do except for changing the model to have more persistence.
2. No, the reference is not the Ravn/Uhlig paper. It’s [Toolkit for Analysing Nonlinear Dynamic Stochastic Models Easily - Oxford Scholarship](https://oxford.universitypressscholarship.com/view/10.1093/0199248273.001.0001/acprof-9780199248278-chapter-3)

---

<div class="post-metadata">

**Author:** ![dsge\_modeling](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@dsge\_modeling](https://forum.dynare.org/u/dsge_modeling)\
**Post date:** [4 November 2021 15:42 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/3 "2021-11-04T15:42:44Z")

</div>

Hi. I was checking the Uhlig reference, and I’m wondering if that frequency-domain technique in which the spectral density of the state space of the model solution is calculated (therefore allowing for obtaining filtering moments without simulations), is the same technique used by Dynare when solving the model at 2nd order and requesting theoretical moments. I mean if theoretical moments are obtained the same way in 1st and 2nd order stochastic solution in Dynare. Thank you.

---

<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:** [4 November 2021 17:54 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/4 "2021-11-04T17:54:02Z")

</div>

Without pruning, the answer is yes. Dynare provides a second order accurate approximation to the moments. For that the linear decision rules are sufficient (combined with what Uhlig suggests)

---

<div class="post-metadata">

**Author:** ![dsge\_modeling](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@dsge\_modeling](https://forum.dynare.org/u/dsge_modeling)\
**Post date:** [4 November 2021 18:40 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/5 "2021-11-04T18:40:51Z")

</div>

Thanks! Also another thing comes to my mind, how exactly does Dynare compute irfs at 2nd order when not using any simulation?

---

<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:** [5 November 2021 07:16 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/6 "2021-11-05T07:16:56Z")

</div>

IRFs at order=2 are always simulation-based, i.e. GIRFs.

---

<div class="post-metadata">

**Author:** ![dsge\_modeling](https://forum.dynare.org/letter_avatar_proxy/v4/letter/d/9de053/32.png) [@dsge\_modeling](https://forum.dynare.org/u/dsge_modeling)\
**Post date:** [5 November 2021 14:30 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/7 "2021-11-05T14:30:34Z")

</div>

Following that, does it make any difference in the resulting IRFs if I just use one shock (i.e. zero sdterr for all but one shock), or is that wrong? I’m aware Dynare orthogonalizes every shock, but how can I make sure that no matter which other shocks I use at the same time the resulting IRFs are pure?

I ask this since in my irfs analysis routine, I want to activate each shock at a time when computing irfs, but I don’t know if this would be wrong.

Thanks.

---

<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:** [5 November 2021 18:52 UTC](https://forum.dynare.org/t/hp-filter-data-and-theoretical-moments/19181/8 "2021-11-05T18:52:20Z")

</div>

That would generally be wrong. The standard deviation of all shocks will affect the point of the state space where the IRFs are computed.
