# Dynare and GMM/SMM sample code

**URL:** <https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146>\
**Category:** SMM/GMM/IRF-Matching\
**Created:** [25 November 2015 07:12 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146 "2015-11-25T07:12:27Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jint83](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@jint83](https://forum.dynare.org/u/jint83)\
**Post date:** [25 November 2015 07:12 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146/1 "2015-11-25T07:12:27Z")

</div>

Is there an example where the parameters in a mod file are estimated with GMM or Simulated Method of Moments, instead of using the Bayesian MCMC type of procedure. A reference paper with complete package of codes would be appreciated, Thanks. I searched AER and Econometrica codes and found nothing. A minimal example would suffice.

---

<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:** [25 November 2015 09:14 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146/2 "2015-11-25T09:14:37Z")

</div>

Please have a look at the replication file for Born/Pfeifer (2014): “Risk Matters: A comment” at [aeaweb.org/articles.php?doi=10.1257/aer.104.12.4231](https://www.aeaweb.org/articles.php?doi=10.1257/aer.104.12.4231).

---

<div class="post-metadata">

**Author:** ![jint83](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@jint83](https://forum.dynare.org/u/jint83)\
**Post date:** [25 November 2015 21:10 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146/3 "2015-11-25T21:10:31Z")

</div>

Thanks. There are a lot of files. Which file minimizes the " quadratic form of the distance of the model moments to the data moments"?

---

<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:** [26 November 2015 08:45 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146/4 "2015-11-26T08:45:21Z")

</div>

At the end of the mod-file, you can see that we optimize over smm\_diff\_function.m

---

<div class="post-metadata">

**Author:** ![jint83](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/59ef9b/32.png) [@jint83](https://forum.dynare.org/u/jint83)\
**Post date:** [27 November 2015 18:25 UTC](https://forum.dynare.org/t/dynare-and-gmm-smm-sample-code/5146/5 "2015-11-27T18:25:34Z")

</div>

I can see that the moments you are trying to match are:

```auto
[quote] moments_emp(1,1)=4.77; //sigma_Y
    moments_emp(2,1)=1.31; //sigma_C/sigma_Y
    moments_emp(3,1)=3.81; //sigma_I/sigma_Y
    moments_emp(4,1)=39.33/100; //std(NX); additional 100 to counteract FV et al.'s division by 100 
    moments_emp(5,1)=-0.76; //corr(NX,Y)
    moments_emp(6,1)=moments_emp(4,1);
    moments_emp(7,1)=moments_emp(5,1);
    moments_emp(8,1)=1.78; //NX_Y at EMAS
[/quote]

```

And I can see that your smm\_diff\_function.m can take shock as an argument. That is to say you can give a sequence of shocks for the simulations to run on, and the moments are estimated off the paths with this particular sequence of shocks.

My question is, I am not trying to match any particular ‘moment’ per se, but I am trying to match the ‘path’ of historical Argentina GDP , with my simulated path of Argentina GDP, given an exogenously sequence of shocks. When I run dynare simulations on my mod file, I always give a particular sequence of shocks to reflect real world events. The sequence of shocks are completely exogenously given, not free parameters, but model parameters such as consumer habit persistence are free parameters. The objective is to ‘find’, through your minimization procedure, the best model parameter so that when my simulated Argentina GDP is plotted with actual data, they look close to each other. Is there any way to achieve it with your code?
