If calculations after MH take forever

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.

If calculations after MH take forever

Postby gbel » Wed Apr 06, 2011 4:07 pm

After MH iterations, the computations can get stuck on marginal_density.m because of a log(0).

If you have this problem, you can use this fix: using determinant properties, replace log(detSIGMA) with logdetSIGMA that is defined as
logdetSIGMA = 2*log(det(chol(SIGMA)));

See attached file, it's a modification of the 4.2 version of Dynare.

Hope this help!

Gilles
Last edited by gbel on Wed Apr 06, 2011 7:22 pm, edited 1 time in total.
gbel
 
Posts: 33
Joined: Thu Sep 04, 2008 8:34 pm
Location: Québec

Re: If calculations after MH take forever

Postby gbel » Wed Apr 06, 2011 7:21 pm

A better idea is:
logdetSIGMA = 2*sum(log(diag(chol(SIGMA))));

That way, the estimated model can grow even more before the loss of precision becomes a problem.

I updated the marginal_density.m file.

Gilles
Attachments
marginal_density.m
(4.63 KiB) Downloaded 486 times
gbel
 
Posts: 33
Joined: Thu Sep 04, 2008 8:34 pm
Location: Québec

Re: If calculations after MH take forever

Postby olayenidynare » Thu Jul 21, 2011 11:27 am

This is so useful. The estimation that used to take about 60 mins takes less than 12 mins!!!!!

Many thanks for sharing this file. But what if there is no log(0) problem? Is the same modified file still useful?
olayenidynare
 
Posts: 22
Joined: Sat Feb 21, 2009 3:17 pm

Re: If calculations after MH take forever

Postby gbel » Fri Jul 22, 2011 8:06 pm

Yes.

The formula is exact (you can check for fun). In fact, it's more precise for all computations.

Gilles
gbel
 
Posts: 33
Joined: Thu Sep 04, 2008 8:34 pm
Location: Québec


Return to Dynare contributions and examples

Who is online

Users browsing this forum: No registered users and 2 guests