Hey all!
Does anybody know how to save the loglikehood and logpost functions coming from mode_check?
Thanks a lot!
In mode_check.m you have to save the variables z and y after line 120, i.e. after
plot(z,y);
z stores the parameter, the first column of y the loglikelihood and the second column the logposterior.
Thanks a lot, that worked!!
Btw, I think it’s on the other way around; the first column of y the logposterior and the second column the loglikelihood.
Of course you are right. Sorry, my mistake.
No worries.
How could it be that for some paramaters the mode does not coincide with the maximum of the logposterior? I thought the mode was precisely the point where the logposterior attains it’s maximum. Thanks!
Susana, I’m not sure exactly what problem you are running in to. The mode of the parameters is vector of parameters that maximizes the posterior distribution.
However, there are ways that things might seem or be off.

The posterior distribution is a highdimensional object. If you look at each marginal distribution (the distribution over draws of some particular parameter in the vector of parameters), it may appear that the posterior density is higher at another spot. This is because the marginal is ignoring the interplay between each distribution.

The mode returned by maximizing the log posterior could fail to be a global maximum if the maximizing algorithm converged before finding the global max.
Thanks bkjecn for your reply!
My problem is that I’m trying to compute the “highest” mode (the global maximum). For that purpose, I repeatedly apply an optimizer to the likelihood function with initial conditions found by sampling 50100 times from a uniform distribution (overdispersed with respect to the prior). I obtain the mode for each parameter and the corresponding value for the posterior density evaluated at the mode. Then, ideally I would compare the posterior densities and choose the mode corresponding to the highest one.
However, here is where my problem arises; I was expecting to obtain the same value for the posterior density when evaluating it at each of the parameters’ mode (in one simulation). Instead, when evaluating the mode at the posterior density, I get that for some parameters it is higher than for others. Why didn’t the optimizer (in the cases with lower density) chose some other value to attain the higher posterior density? Could it be because my algorithm is converging before finding the global maximum? What would it be a good method to choose the “best” mode? Thank you very much for your time!
Most probably your optimization algorithm does stop prematurely. One way could be to restart the optimization with e.g. mode_compute=6 from the point where the last try stopped. Also, you could download the latest snapshot of Dynare unstable and try mode_compute=9. This should trigger the CMAES algorithm, a global optimizer. While it might take some time, the results are often better than using Newtonbased optimizers.