Errors in Bayesian estimation(matrix must be a positive definite)

Dear all,
I am building a DSGE model about land use, however, my code have some problems with Bayestian estimation, I have tried mode_compute=6,8 and 9, errors always exist in my estimation.But the code without estimation works. Here are my code files with an without estimation. Could you help me sovle may problem? Thanks a lot.
data.mat (3.9 KB)
paper_without_estimation.mod (3.8 KB)
paper_with_estimation.mod (3.8 KB)

Errors in estimation file:
Configuring Dynare …
[mex] Generalized QZ.
[mex] Sylvester equation solution.
[mex] Kronecker products.
[mex] Sparse kronecker products.
[mex] Local state space iteration (second order).
[mex] Bytecode evaluation.
[mex] k-order perturbation solver.
[mex] k-order solution simulation.
[mex] Quasi Monte-Carlo sequence (Sobol).
[mex] Markov Switching SBVAR.

Using 64-bit preprocessor
Starting Dynare (version 4.5.3).
Starting preprocessing of the model file …
Found 22 equation(s).
Evaluating expressions…done
Computing static model derivatives:

  • order 1
    Computing dynamic model derivatives:
  • order 1
  • order 2
    Processing outputs …
    Preprocessing completed.

Residuals of the static equations:

Equation number 1 : 0
Equation number 2 : 0
Equation number 3 : 0
Equation number 4 : 0
Equation number 5 : 0
Equation number 6 : 0
Equation number 7 : 0
Equation number 8 : 0
Equation number 9 : 0
Equation number 10 : 0
Equation number 11 : 0
Equation number 12 : 0
Equation number 13 : 0
Equation number 14 : 0
Equation number 15 : 0
Equation number 16 : 0
Equation number 17 : 0
Equation number 18 : 0
Equation number 19 : 0
Equation number 20 : 0
Equation number 21 : 0
Equation number 22 : 0

Warning: Some of the parameters have no value (sigma) when using steady. If these parameters are not
initialized in a steadystate file or a steady_state_model-block, Dynare may not be able to solve the


ch 0
ql 0
w 0
n 0
s 0
lh 0
r 0
k 0
le 0
g 0
ce 0
b 0
i 0
y 0
lamdae 0
qk 0
d 0
lamdag 0
theta 0
a 0
l 0
c 0

Modulus Real Imaginary

   1.078e-18        1.078e-18                0
   4.075e-16       -4.075e-16                0
   5.263e-14        5.263e-14                0
     0.07531          0.07531                0
        0.75             0.75                0
        0.75             0.75                0
        0.75             0.75                0
      0.8994           0.8994                0
       1.153            1.153          0.01166
       1.153            1.153         -0.01166
       3.356            3.356                0
   1.662e+14        1.662e+14                0
   8.313e+15        8.313e+15                0
         Inf              Inf                0

There are 6 eigenvalue(s) larger than 1 in modulus
for 6 forward-looking variable(s)

The rank condition is verified.

You did not declare endogenous variables after the estimation/calib_smoother command.
Warning: Some of the parameters have no value (sigma) when using initial_estimation_checks. If these
parameters are not initialized in a steadystate file or a steady_state_model-block, Dynare may not be
able to solve the model…
Initial value of the log posterior (or likelihood): -60327451975825.97

Change in the posterior covariance matrix = 0.01.
Change in the posterior mean = 0.43758.
Mode improvement = 60142816749032.44
New value of jscale = 1.1384e-12

Change in the posterior covariance matrix = 8.9627e-14.
Change in the posterior mean = 0.4222.
Mode improvement = 476760259346.6788
New value of jscale = 4.6107e-14

Error using chol.
The matrix must be a positive definite matrix.

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

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

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

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

Error dynare_estimation (line 105)

Error paper_with_estimation (line 333)

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

Try the mode check command. This error message can sometimes come up, when the priors are tight and the optimisation hits the boundary…

It is better to use looser priors for the shock volatilities
seems to be a tight prior for a stdev.

also, the model seems to be a log-linear one…should you not be using a model(linear) option…?


1 Like

Your observation equation is wrong. You are trying to match trending data to stationary model variables. Please read Pfeifer(2013): “A Guide to Specifying Observation Equations for the Estimation of DSGE Models”

Dear Reuben, thank you for your helping. I have realized that it is the data used in the estimation is wrong and I have solved the problem, thanks again.

Dear jpfeifer, thanks for your helping, the problem is the wrong data I used, and I have tried to solve it. Thanks for your help again.
May I have another question? I am now in trouble with shocks. I have read your code in


    var eps_z_news=1; //8 period anticipated TFP news shock

    var eps_z_surprise=1; //TFP surprise shock


// set shocks for pure news

shock_matrix(1,strmatch('eps_z_news',M_.exo_names,'exact')) = 1; %set news shock to 1 (use any shock size you want)

shock_matrix(1+8,strmatch('eps_z_surprise',M_.exo_names,'exact')) = -1; %8 periods later use counteracting shock of -1

My problem is what the size of the shock means? Does ‘set news shock to 1’ mean that it is the same as ‘var eps_z_news=1’? And is it a feasible way to combine two shocks at the same time?
If my code is
var eps_theta;stderr 0.01;
var eps_l;stderr 0.01;
var eps_a;stderr 0.01;
how could I combine the eps_theta (stderr 0.01) and eps_l (stderr 0.01) shocks at the same time? Thanks a lot.
Yours sincerely

What are you trying to do? The code you refer to is about simulating with a pre-specified shock size. In contrast, the shocks-block is about specifying the distribution of shocks.

Dear professor, thanks for your reply. Actually I just want to combine the shocks eps_theta and eps_l at the same time, and making the eps_l shock an adverse way, I do not know if it is possible to realize it through your code I referred. Thanks a lot again.

Combine them for what? For an IRF? If yes, the code applies.