Page 1 of 1

Saving log-like and log-post

PostPosted: Fri Apr 13, 2012 3:23 pm
by Susana
Hey all!
Does anybody know how to save the log-likehood and log-post functions coming from mode_check?
Thanks a lot!

Re: Saving log-like and log-post

PostPosted: Wed Apr 18, 2012 8:34 pm
by jpfeifer
In mode_check.m you have to save the variables z and y after line 120, i.e. after
Code: Select all
plot(z,-y);

z stores the parameter, the first column of y the log-likelihood and the second column the log-posterior.

Re: Saving log-like and log-post

PostPosted: Fri Apr 20, 2012 2:40 pm
by Susana
Thanks a lot, that worked!!

Re: Saving log-like and log-post

PostPosted: Mon Apr 23, 2012 6:20 pm
by Susana
Btw, I think it's on the other way around; the first column of y the log-posterior and the second column the log-likelihood.

Re: Saving log-like and log-post

PostPosted: Mon Apr 23, 2012 9:01 pm
by jpfeifer
Of course you are right. Sorry, my mistake.

Re: Saving log-like and log-post

PostPosted: Mon Apr 23, 2012 10:10 pm
by Susana
No worries.

How could it be that for some paramaters the mode does not coincide with the maximum of the log-posterior? I thought the mode was precisely the point where the log-posterior attains it's maximum. Thanks!

Re: Saving log-like and log-post

PostPosted: Tue Apr 24, 2012 1:52 pm
by bkjecn
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.

1) The posterior distribution is a high-dimensional 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.

2) 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.

Re: Saving log-like and log-post

PostPosted: Tue Apr 24, 2012 7:09 pm
by Susana
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 50-100 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!

Re: Saving log-like and log-post

PostPosted: Tue Apr 24, 2012 9:03 pm
by jpfeifer
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 Newton-based optimizers.