Bugfix (?) for positive definiteness failure

Hi everyone!

Once in a while, you may get a failure of positive definitness at line 52 of metropolis_hastings_initialization, on “d = chol(vv);”.

This can be caused, I think, when you have an unidentified parameter that has a weak gamma prior. But it also happens sometimes when you use newrat (option mode_compute=5), because mr_hessian returns a complex-valued Hessian matrix. I haven’t been able to figure out why that happens, but here is a workaround that seems to paper over the problem succesfully. In dynare_estimation, just after line 410, insert these lines:

if(any(any(~isreal(hh)))) if ~options_.bvar_dsge hh = reshape(hessian('DsgeLikelihood',xparam1,gend,data),nx,nx); else hh = reshape(hessian('DsgeVarLikelihood',xparam1,gend),nx,nx); end end

…so that Dynare will fall back to the standard Hessian estimator if newrat’s doesn’t work.


I believe that I also am experiencing crashes due to this problem. I want to try using your fix, but cannot find line 410 in dynare.estimation.m. There are not that many lines of code in this file. I would guess that you are not using the most recent subversion? Assuming this to be the case I have added your fix after line 421 in the file dynare_estimation_1.m. Unfortunately, this did not solve my problem. (So perhaps I have not put the patch in the right place?)

What is my problem? I ran RBC_Datagen.mod from \doc\userguide\models which comes with dynare. Then I attempted to run RBC_Est.mod. This results in the following error message:

(minus) the hessian matrix at the “mode” is not positive definite!
=> posterior variance of the estimated parameters are not positive.
You should try to change the initial values of the parameters using
the estimated_params_init block, or use another optimization routine.
??? Error using ==> dynare_estimation_1
I cannot go further!

Error in ==> dynare_estimation at 57

Error in ==> RBC_Est at 128

Error in ==> dynare at 102
evalin(‘base’,fname) ;

I think this should be of interest to the makers of Dynare. Their program at least ought to work for the examples they provide with the software. Note: I do not get an error message using the previous subversion of version 4 provided I alter the code in dynare_estimation.m from line 980, which was

eval(‘oo_.UpdatedVariables.’ deblank(M_.endo_names(dr.order_var(i),:)) …
’ = updated variables(i,:)’’;’]);

into the following

eval(‘oo_.UpdatedVariables.’ deblank(M_.endo_names(dr.order_var(i),:)) …
’ = updated_variables(i,:)’’;’]);

Hi, we recently changed dynare (in the trunk of our subversion repository, I did not change the 4.0 branche) so that when minus the hessian matrix at the estimated mode is not positive-definite dynare stops. In previous version dynare (in dynare 4.0.x) we sligthly change the hessian matrix so that minus the hessian becomes positive definite… But there is no true rational for this transformation. When you get this error message it means that your estimated mode is not the mode of the posterior kernel. In this case you have to find another estimate of the mode (by changing the optimization routine or the initial conditions. The problem may be related to the shape of the priors also).


Yes, quite. But I would have sworn that mr_hessian also generates this error when newrat has genuinely found the mode (as evidenced by the mode_check plots and the posterior marginals). I don’t mean to diss newrat, though — the problem is probably in my model somewhere…