A question on mode_file option in Dynare

Dear all,

I encountered a problem in Dynare yesterday and I would appreciate it very much if any one of you could give me some hints.

I started from a certain parameter vector and use mode_compute=6 to find the mode and then run MCMC. The mode finally found indicates that the minus log posterior density equal to 831.3037. This is in the log file (experiment_modefile.log). The mode file (mymode.mat) has been attached as well. Then I did an experiment. On one hand, I copy the parameter values in the mode_file and paste in the parameter block of the mod file (experiment_modefile.mod). Then I allow the estimated_params_init(use_calibration) block. Then I use the estimation command without mode_file option to do the estimation again. In principle, the initial minus log posterior density should also equal to 831.3037. It turns out to be the case. On the other hand, I shut down the calibration part in the parameter block and also shut down the estimated_params_init(use_calibration) block. This time, I use mode_file option in the estimation command. Surprisingly, the initial minus log posterior density equals to 849.8676, which is significantly different from 831.3037. I am not sure what the problem is. Did I make any mistake in using the mode_file option?

For your reference, I have zipped all the files necessary to run the code.

Thanks a lot!


experiment_modefile.rar (16.3 KB)

Which Dynare version are you using?

This is a bug with the use_calibration option that will be fixed soon. Thanks for reporting it.

The mode-file option yields the correct result. The reason why it occurs in your case is that your steady state file returns 0 instead of NaN for the observables when the steady state cannot be solved. See github.com/DynareTeam/dynare/issues/691. We must check for this case in the future.

Thanks so much for the reply! I was using Dynare unstable version “2014-07-11”.

For my case, is there any way to get the mode-file option working correctly? Do I need to modify my steadystate file? I would appreciate it very much if you could be more specific. I am not sure if I could understand the bug you mentioned in the previous post. But right now, the use_calibration option seems to be working for my case.

By the way, the link github.com/DynareTeam/dynare/pull/691 you provided is about variance decompostion. Is it related to my problem?

Sorry, I meant github.com/DynareTeam/dynare/pull/698.
You can replace your Dynare files with the attached ones and everything should work.
dynare_estimation_1.m (49 KB)
dynare_estimation_init.m (22.7 KB)

Thanks a lot for the instruction! I replaced the two m files and both the mode-file option and the use_calibration option provides the same log posterior (849.8676), given the same parameter values in mode_file.

To understand Dynare better, now one question remains. Please refer to the log file in the zipped file in my original post. In the log, it says “Final value of the log posterior (or likelihood): 831.3037” right after the mode computation. My question: is 831.3037 associated with the mode? If yes, why is the initialized log posterior in my subsequent exercise 849.8676? If not, what is 831.3037 and why is 849.8676 (which is supposed to the mode posterior) not showing up in the log file? Since I am not very clear about the way Dynare works, I am wondering if the bug you mentioned affects the whole estimation? If yes, is 831.3037 just an error due to the bug?

Thank you!

What happened is that Dynare erroneously concluded that your observation equations have no constant. Under this wrong assumption, you get the 831. Note that this mode is wrong for this reason. Now when loading the mode-file, Dynare concludes that there is a constant in the equation. The result is the displayed 849. However, the parametrization in both cases is the same. The only difference was the incorrect data treatment. For this reason, after fixing the bug using the attached files, you need to rerun the mode-finding. After that, all numbers you get should be the same.

Dear Johannes,

As you said, I run the mode_compute again. And all the subsequent problems disappear. Thanks a lot!

By the way, has the bug been fixed in the latest version of the unstable Dynare? Or should people manually update the two files to avoid the bug?

Also, after running Dynare, there is a file named “filename_mh_mode.mat”, which is different from the mode file from mode_compute. I am wondering what this file is? Is it the mode after running the metropolis-hastings?

Thank you!



It’s not yet in the unstable. You can find the status here: dynare.org/DynareWiki/KnownBugs

Yes, the mh_mode-file is the mode after running the MCMC.

I see. Thank you, Johannes.