Avoiding MCMC failure with non positive definite Hessian
Posted: Mon May 19, 2014 4:19 am
Hi everyone,
I really like the way Dynare implements MCMC estimation --- many thanks to the Dynare team for all your efforts! --- but there's one situation that it doesn't handle that well. During model development, it's not unusual to have an estimated Hessian at the mode that's not positive definite. One parameter might be dodgy, or it might be hard to find the mode, or there may be scaling problems between different parameters, etc. In those cases, Dynare prints a warning but then causes a Matlab error on line 68 of metropolis_hastings_initialization.m, on the line d = chol(vv);
Sometimes you may want to run Metropolis Hastings anyway for a while, because that often helps to find the real mode and/or to identify which parameters are causing a problem. Here's the code I use to do that. If you like, you can drop it in as a replacement for line 68 of metropolis_hastings_initialization.m.
Jamie
I really like the way Dynare implements MCMC estimation --- many thanks to the Dynare team for all your efforts! --- but there's one situation that it doesn't handle that well. During model development, it's not unusual to have an estimated Hessian at the mode that's not positive definite. One parameter might be dodgy, or it might be hard to find the mode, or there may be scaling problems between different parameters, etc. In those cases, Dynare prints a warning but then causes a Matlab error on line 68 of metropolis_hastings_initialization.m, on the line d = chol(vv);
Sometimes you may want to run Metropolis Hastings anyway for a while, because that often helps to find the real mode and/or to identify which parameters are causing a problem. Here's the code I use to do that. If you like, you can drop it in as a replacement for line 68 of metropolis_hastings_initialization.m.
- Code: Select all
[ d, notPosDef ] = chol(vv);
if notPosDef
disp('Warning: using diagonal proposal covariance.');
diagv = diag(vv);
diagv(diagv < 0) = 1e-5;
d = diag(sqrt(diagv));
end
Jamie