Dear all,

I am using SMM to calibrate some parameters of a macro model, using moments from Dynare. The moments I am using are the 2nd order theoretical moments from Dynare.

I have recently noticed that running the exact SMM estimation code twice gives me *slightly* different results. The reason, I believe, is that Dynare produces slightly different 2nd order theoretical moments each time a Mod file is run. For example, when I run a mod file twice in a row:

dynare test

dynare test

It produces two slightly different 2nd order theoretical moments for output – 0.341028224054378 the first time, 0.341028224054382 the second time.

These slight differences, combined with the flatness of my SMM objective function, means that I get *slightly* different estimation results each time the SMM is run.

My question is thus, is there any way for Dynare to produce the exact same 2nd order theoretical moments each time it is run? I have tried setting the dynare and Matlab seed, but this does not seem to do the trick.

Many thanks,

Jake

That is very strange. Which version of Dynare, Matlab and which OS are you using?

Thanks for your response!

Matlab 8.3.0.532 (R2014a)

Dynare 4.4.3

OSX El Capitain (10.11.6)

I’ve been doing some experimenting, and there seem to be a few ways to get rid of the error. I have attached three files:

(1) error_replicate.mod – running this over and over again, then displaying the results (num2str(oo_.mean(1:13),’%04.20f’)) shows that there are once again *slightly* different results. However, sometimes the results are exactly the same for a bunch of runs in a row, only for them to be different.

(2) no_error_1.mod – I got rid of a bunch of variables that simply calculate summary statistics, and the error went away.

(2) no_error_2.mod — I changed up my code a little by changing some of the equations, and this for some reason got rid of the error. In particular, I changed how I defined the “m” variable.

Very confused,

Jake

no_error_2.mod (5.3 KB)

error_replicate.mod (5.2 KB)

no_error_1.mod (4.4 KB)

That is indeed strange. It seems to come from slight differences in the parameter vector `M_.params`

, i.e. the differences are already there before anything is computed. I ran

```
for ii=1:10
dynare error_replicate
temp(:,ii)=oo_.mean(1:13);
temp2(:,ii)=oo_.dr.ys;
temp3(:,ii)=M_.params;
end
```

and differences are in all objects.

Thanks for looking into this!

Strange… I’m running the above code, and I’m not seeing any differences in temp2 or temp3 – only temp1! The mystery deepens… maybe I should update Dynare?

Jake

My mistake. I actually cannot replicate the issue on my machine. Running

```
for ii=1:10
dynare error_replicate
temp(:,ii)=oo_.mean(1:13);
temp2(:,ii)=oo_.dr.ys;
temp3(:,ii)=M_.params;
end
max(abs(temp-repmat(temp(:,1),1,10)),[],2)
max(abs(temp2-repmat(temp2(:,1),1,10)),[],2)
max(abs(temp3-repmat(temp3(:,1),1,10)),[],2)
```

returns only zeros

Updating Matlab to R2017b did the trick. Thanks for your help!

Jake