Code running into problem

Hi all,

My code was running properly without errors, somehow I have error messages such as “prior distribution for parameters XX has unbounded density”
"Warning: gmhmaxlik: Unknown option (MaxIter)! "

Then at some point dynare just stops working without finishing the Bayesian estimation.

I have updated to the most recent Dynare 4.5.5 version, maybe this is causing problem?

Hope to get some insights!

The first message is a warning that you use a prior distribution you should not use. Your prior implies an infinite density at the bound of the parameter space. A powerful optimizer should recognize that this may be global optimum, leading to problems in estimation.
The second message suggest that you are using an old syntax for controlling mode_compute=6. What is the problem you encounter after mode-finding?

For the prior distribution I just follow the literature use Gamma and Beta distribution and set the lower and upper bound to be 0.0000001 and 0.999999. Do you mean I should use a different kind of distribution or different upper or lower bound values?

After several rounds of posterior estimation Dynare just stops, for example:

Change in the posterior covariance matrix = 4.
Change in the posterior mean = 8.9999.
Mode improvement = 167582702.3443
New value of jscale = 7.3019e-05

Change in the posterior covariance matrix = 0.00021355.
Change in the posterior mean = 8.9999.
Mode improvement = 167580397.4905
New value of jscale = 1.3039e-14

Error using chol
Matrix must be positive definite.

Error in gmhmaxlik_core (line 194)
dd = transpose(chol(CovJump));

Error in gmhmaxlik (line 100)
[PostMode, PostVariance, Scale, PostMean] = gmhmaxlik_core(fun, OldPostMode,
bounds, gmhmaxlikOptions, Scale, flag, MeanPar, OldPostVariance, varargin{:});

Error in dynare_minimize_objective (line 254)
[opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function,
start_par_value, …

Error in dynare_estimation_1 (line 220)
[xparam1, fval, exitflag, hh, options_, Scale, new_rat_hess_info] =

Error in dynare_estimation (line 105)

Error in simple8 (line 615)

Error in dynare (line 235)
evalin(‘base’,fname) ;

Warning: A value of class “” was indexed with no subscripts
specified. Currently the result of this operation is the indexed value itself, but in a future
release, it will be an error.

In matlab.internal.VideoReader/createChannel (line 495)
In matlab.internal.VideoReader (line 192)
In VideoReader/init (line 598)
In VideoReader (line 171)
In finfo>getVideoInfo (line 205)
In finfo>openAsMultimediaFile (line 194)
In finfo (line 79)
In open (line 115)
In uiopen (line 175)

When I use mode_compute=9, I often get the warning:
Warning: Non-finite fitness range

In cmaes (line 974)
In dynare_minimize_objective (line 360)
In dynare_estimation_1 (line 220)
In dynare_estimation (line 105)
In simple8 (line 615)
In dynare (line 235)

And some results like this:

prior mean mode s.d. prior pstdev

rhoR 0.750 0.7941 NaN beta 0.1500
rpi 1.200 1.1392 NaN gamm 0.0500
rdeltay 0.200 0.4434 NaN gamm 0.0500
b 0.660 0.7650 NaN beta 0.1000
alfa 0.330 0.1710 NaN beta 0.0300
s 0.850 0.8550 NaN beta 0.0500
DSHARE 0.318 0.1196 NaN beta 0.1000
sigma 0.500 0.7234 NaN beta 0.1000
rho_g 0.700 0.1717 NaN beta 0.2000
rho_w 0.700 0.6510 NaN beta 0.2000
rho_nD 0.700 0.6496 NaN beta 0.2000
rho_t 0.700 0.4825 NaN beta 0.2000
rho_i 0.700 0.2989 NaN beta 0.2000
rho_nH 0.700 0.9177 NaN beta 0.2000
rho_lp 0.700 0.7202 NaN beta 0.2000
rho_me 0.700 0.5616 NaN beta 0.2000
rho_Ome 0.700 0.2432 NaN beta 0.2000
rho_lq 0.700 0.6188 NaN beta 0.2000
rho_gb 0.500 0.6771 NaN gamm 0.2500
rho_wb 0.500 0.6160 NaN gamm 0.2500
rho_nDb 0.500 0.5114 NaN gamm 0.2500
rho_gy 0.050 0.1116 NaN norm 0.0500
rho_wy 0.150 0.0804 NaN norm 0.0500
rho_nDy 0.150 0.2994 NaN norm 0.0500

standard deviation of shocks
prior mean mode s.d. prior pstdev

mpol_eps 0.100 0.0118 NaN invg 2.0000
mpol_g 0.100 3.1587 NaN invg 2.0000
mpol_w 0.100 2.0438 NaN invg 2.0000
mpol_nD 0.100 0.8676 NaN invg 2.0000
mpol_t 0.100 4.8834 NaN invg 2.0000
mpol_i 0.100 5.8172 NaN invg 2.0000
mpol_nH 0.100 2.6733 NaN invg 2.0000
mpol_lp 0.100 4.6842 NaN invg 2.0000
mpol_me 0.100 4.3395 NaN invg 2.0000
mpol_Ome 0.100 4.8172 NaN invg 2.0000
mpol_lq 0.100 0.8281 NaN invg 2.0000

Log data density [Laplace approximation] is NaN.

Error using chol
Matrix must be positive definite with real diagonal.

Error in posterior_sampler_initialization (line 84)
d = chol(vv);

Error in posterior_sampler (line 60)
posterior_sampler_initialization(TargetFun, xparam1, vv,

Error in dynare_estimation_1 (line 448)

Error in dynare_estimation (line 105)

Error in simple8 (line 615)

Error in dynare (line 235)
evalin(‘base’,fname) ;

  1. How do the mode_check-plots look like?
  2. For the unbounded density, see Unbounded density

Hi Professor,

I try mode_check, except for some parameters have red dots clustering, most looked normal. When combine with mode_compute=9, there are always at the prior bound problems, I tried to change the prior mean, tune down the standard deviation or change the upper or lower bound, but the error message would not go away.

However when I try the mode_compute=6 (the only working one) I did get one model file working. Which I have no idea why…

If you run into the prior bounds, this indicates deeper issues like a wrong data treatment

I am having an issue of “using chol Matrix must be positive definite” after few MH iterations. I am unable to figure it out. I have attached the mod file. I would be obliged for your help.Paper_Estimate_Bayesian.mod (6.3 KB)


If I use option “mcmc_jumping_covariance = prior_variance”, it seems to working fine. Default is “mcmc_jumping_covariance = Hessian”. What differences it makes to my estimation? Looking forward to your kind response.


I have another related question. I am getting very low acceptance rate for RW MH. What could be the possible reason and how to improve it. I have already change jump scale but it didn’t help.
Thank You

I use the log difference of the data and the measurement equation is just the linearly detrended by the quarterly growth rate of the data. Maybe one problem with the data is I use the unemployment benefits data which is very volatile and had negative average growth rate.

Another thing I found very strange is in the Historical Variance Decomposition, all data related variables seem to have the same picture, in terms of the magnitude and location of the variance decomposition by each shock. Does this also indicate something fundamental?


I am having the problem of “(minus) the hessian matrix at the “mode” is not positive definite!” in attached mod file. I have changedPaper_3.mod (5.7 KB)
optimisation routines but is of no help. I would be obliged if you can help.

In both cases I would need to see the mod-file and the data files or at least the mode_check plots.
@gdp As I said, running into the prior bounds usually indicates some more fundamental problems. Which economic parameters are the one that run into the bound?
@abhishek Any positive definite covariance matrix as the proposal density will work. The identity may simply be less efficient. But using a different matrix is not a substitute for solving the typical problems with the model that give rise to the Hessian at the conjectured mode not being positive definite

Thanks for your kind response. Please find attached mod files and data. data_nk.mat (5.5 KB)
Paper_3.mod (5.7 KB)
Paper_Estimate_Bayesian.mod (6.5 KB)

Paper_3.mod does likelihood estimation while the other mod file does Bayesian estimation. Both of them use same data attached.


  1. You have stochastic singularity as you observe all components of the budget constraint.
  2. Your inflation series seems to have a massive seasonal pattern.
  3. npaobs has a strange step function at the end of the sample that may give the optimizer trouble
  4. Try mode_compute=5

Dear Sir,

Thanks for your kind response.

Could you please elaborate on point 1.

I dropped inflation and npaobs from observables but still having the problem of “(minus) the hessian matrix at the “mode” is not positive definite!” in attached mod file.

Paper_4.mod (5.6 KB)

Dear Sir,

And if I have understood your point 1 correctly, even after dropping cobs as observables gives the problem of “(minus) the hessian matrix at the “mode” is not positive definite!”. Kindly have a look.

Did you solve issues 2 and 3 or at least 2? You did not provide any new data.

Dear Sir,

I dropped both of them from observables. I am no longer estimating model using them. But still the problem persist.

Have a look at the mode_check-plots. There are several parameters that are problematic. You may have to go for Bayesian estimation instead of ML.