If calculations after MH take forever

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

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
marginal_density.m (4.63 KB)

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?

Yes.

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

Gilles