Saving log-like and log-post

This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location where you will have to reset your password.
Forum rules
This forum is closed. You can read the posts but cannot write. We have migrated the forum to a new location (https://forum.dynare.org) where you will have to reset your password.

Saving log-like and log-post

Postby Susana » Fri Apr 13, 2012 3:23 pm

Hey all!
Does anybody know how to save the log-likehood and log-post functions coming from mode_check?
Thanks a lot!
Susana
 
Posts: 9
Joined: Wed Mar 28, 2012 4:27 pm

Re: Saving log-like and log-post

Postby jpfeifer » Wed Apr 18, 2012 8:34 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Saving log-like and log-post

Postby Susana » Fri Apr 20, 2012 2:40 pm

Thanks a lot, that worked!!
Susana
 
Posts: 9
Joined: Wed Mar 28, 2012 4:27 pm

Re: Saving log-like and log-post

Postby Susana » Mon Apr 23, 2012 6:20 pm

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.
Susana
 
Posts: 9
Joined: Wed Mar 28, 2012 4:27 pm

Re: Saving log-like and log-post

Postby jpfeifer » Mon Apr 23, 2012 9:01 pm

Of course you are right. Sorry, my mistake.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany

Re: Saving log-like and log-post

Postby Susana » Mon Apr 23, 2012 10:10 pm

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!
Susana
 
Posts: 9
Joined: Wed Mar 28, 2012 4:27 pm

Re: Saving log-like and log-post

Postby bkjecn » Tue Apr 24, 2012 1:52 pm

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.
bkjecn
 
Posts: 35
Joined: Thu Oct 13, 2011 3:02 am

Re: Saving log-like and log-post

Postby Susana » Tue Apr 24, 2012 7:09 pm

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!
Susana
 
Posts: 9
Joined: Wed Mar 28, 2012 4:27 pm

Re: Saving log-like and log-post

Postby jpfeifer » Tue Apr 24, 2012 9:03 pm

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.
------------
Johannes Pfeifer
University of Cologne
https://sites.google.com/site/pfeiferecon/
jpfeifer
 
Posts: 6940
Joined: Sun Feb 21, 2010 4:02 pm
Location: Cologne, Germany


Return to Dynare help

Who is online

Users browsing this forum: No registered users and 4 guests

cron