Same Matlab/Dynare different Results


I am running a Bayesian estimation and I get different results after the mode computation (mode_compute=4) on two different computers running Matlab2017a and Dynare 4.5.3.

The results I get on the two computers are always different.

To be sure, I have set:


Which is the default, on both machines. Is there any other source of randomness I should take into account?

Thank you!

Hi, Normally the seed should be the same on each run of Dynare (even without the set_dynare_seed command). Did you check if you obtain the same results with a purely deterministic optimization algorithm (for instance with mode_compute equal to 7 or 8).


Thank you so much for your reply.

With mode_compute=4 I do get the same results for each run on the same computer, but I get different results if I run the optimization on two different computers. I will check with mode_compute 7 or 8 and let you know.

Thank you.

Do the two computers use the same operating system?

No, the two computers use Windows 7 and 10.

Could that be the cause?

In any case, I will test the deterministic optimizations and the same code on two computers running the same OS and let you know the results.

Thank you.

Are both Windows versions 64 bit?

Yes, both windows are 64 bit.

The try a different mode-finder, please. @stepan-a I had a similar thing with mode_compute=4 before, but could not find the source of the difference even after hours of debugging.

Thank you so much.

I actually get different results also with mode_compute=7 and mode_compute=8.

What I just noticed is that also the eigenvalues very close to zero as well as the explosive ones have different values on the two PC.

Could that be something related to the numerical aproximation?

Thanks for experimenting. Even if you are using the same matlab version, it could be that different libraries are used depending on the version OS. This could explain the discrepancies. It would be interesting to see the magnitude of the difference in likelihood evaluations (just by computing the likelihood on a common calibrated set of parameters) and also on the reduced form models (oo_.dr). It’s difficult to do that on my side…


I am currently having the same problem with mode_compute=2 for MATLAB2023a and Dynare 5.4 (but also for MATLAB2021b and Dynare 4.5.4): estimation results differ between computers.

I am reading that mode_compute=2 employs the continuous simulated annealing global optimization algorithm. I have read a little bit about this method, and I understand that in each iteration, a neighbor state is randomly picked during the process. Therefore, I infer that some random number generator is being used in the process of finding the mode with mode_compute=2.

While I understand that the dynare program automatically sets the seed for the Monte-Carlo Markov Chain, the dynare manual does not make it clear whether the seed is also set for the random number generator inside the mode_compute=2 algorithm.

My question: is there a way to set this seed for the process? If yes, could you tell me in which dynare file(s) or MATLAB file?

I would be grateful if you could help me.

For each Dynare run, set_dynare_seed is called, which invokes reset(RandStream.setGlobalStream(s));
That should set the seed for all random number generators. In theory, this should not be the cause for your discrepancies.

So do I understand you correctly that the command “set_dynare_seed” does not only set the seed for the Monte-Carlo Markov Chain, but also for the search for the posterior mode using the continuous simulated annealing global optimization algorithm?

And do you have any idea what could cause the discrepancies, which should theoretically not be possible?

  1. Yes, that is correct.
  2. In the past I experienced rather large differences between Matlab versions due to different versions of the Intel Matrix Kernel Library underlying Matlab.