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 …

done

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

model…

STEADY-STATE RESULTS:

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

EIGENVALUES:

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] =

dynare_minimize_objective(objective_function,xparam1,options_.mode_compute,options_,[bounds.lb

bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);

Error dynare_estimation (line 105)

dynare_estimation_1(var_list,dname);

Error paper_with_estimation (line 333)

oo_recursive_=dynare_estimation(var_list_);

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

inv_gamma2_pdf,0.1,0.01;

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…?

Reuben

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.

Sincerely

Yu

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 https://github.com/JohannesPfeifer/DSGE_mod/blob/master/RBC_news_shock_model/RBC_news_shock_model.mod

```
shocks;
var eps_z_news=1; //8 period anticipated TFP news shock
var eps_z_surprise=1; //TFP surprise shock
end;
```

// 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

shocks;

var eps_theta;stderr 0.01;

var eps_l;stderr 0.01;

var eps_a;stderr 0.01;

end;

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

Yu

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.

Good morning Prof.,

I am currently having the below error message as below:

dynare musa.mod

Using 64-bit preprocessor

Starting Dynare (version 4.6.4).

Calling Dynare with arguments: none

Starting preprocessing of the model file …

Found 28 equation(s).

Evaluating expressions…done

Computing static model derivatives (order 2).

Computing static model derivatives w.r.t. parameters (order 2).

Computing dynamic model derivatives (order 2).

Computing dynamic model derivatives w.r.t. parameters (order 2).

Processing outputs …

done

Preprocessing completed.

Residuals of the static equations:

Equation number 1 : 0 : CR

Equation number 2 : 0 : CVR

Equation number 3 : 0 : TP

Equation number 4 : 0 : w

Equation number 5 : 0 : mc

Equation number 6 : 0 : r

Equation number 7 : 0 : g

Equation number 8 : 0 : d

Equation number 9 : 0 : pii_F

Equation number 10 : 0 : z

Equation number 11 : 0 : piistar

Equation number 12 : 0 : exr

Equation number 13 : 0 : C

Equation number 14 : 0 : pii_D

Equation number 15 : 0 : y

Equation number 16 : 0 : rstar

Equation number 17 : 0 : a

Equation number 18 : 0 : rev

Equation number 19 : 0 : s_d

Equation number 20 : 0 : s_g

Equation number 21 : 0 : s_ff

Equation number 22 : 0 : s_fy

Equation number 23 : 0 : s_b

Equation number 24 : 0 : s_r

Equation number 25 : 0 : s_y

Equation number 26 : 0 : s_df

Equation number 27 : 0 : s_t

Equation number 28 : 0 : s_rn

STEADY-STATE RESULTS:

CR 0

CVR 0

TP 0

w 0

mc 0

r 0

g 0

d 0

pii_F 0

z 0

piistar 0

exr 0

C 0

pii_D 0

y 0

rstar 0

a 0

rev 0

s_d 0

s_g 0

s_ff 0

s_fy 0

s_b 0

s_r 0

s_y 0

s_df 0

s_t 0

s_rn 0

EIGENVALUES:

Modulus Real Imaginary

```
7.872e-17 7.872e-17 0
0.3458 0.2832 0.1985
0.3458 0.2832 -0.1985
0.3802 -0.3802 0
0.65 0.65 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
0.7 0.7 0
1.127 1.127 0
2.395 2.395 0
13.28 12.27 5.074
13.28 12.27 -5.074
7.262e+15 7.262e+15 0
4.328e+16 -4.328e+16 0
```

There are 6 eigenvalue(s) larger than 1 in modulus

for 6 forward-looking variable(s)

The rank condition is verified.

Initial value of the log posterior (or likelihood): -1.549488895571599e+16

#
==========================================================

Change in the posterior covariance matrix = 1.

Change in the posterior mean = 1.8747.

Mode improvement = 1.549488871149786e+16

New value of jscale = 2.4646e-08

#
==========================================================

Change in the posterior covariance matrix = 2.9406e-11.

Change in the posterior mean = 1.8086.

Mode improvement = 255417643492.7751

New value of jscale = 4.7408e-18

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 323)

[opt_par_values, hessian_mat, Scale, fval] = gmhmaxlik(objective_function,

start_par_value, …

Error in dynare_estimation_1 (line 228)

[xparam1, fval, exitflag, hh, options_, Scale, new_rat_hess_info] =

dynare_minimize_objective(objective_function,xparam1,options_.mode_compute,options_,[bounds.lb

bounds.ub],bayestopt_.name,bayestopt_,hh,dataset_,dataset_info,options_,M_,estim_params_,bayestopt_,bounds,oo_);

Error in dynare_estimation (line 105)

dynare_estimation_1(var_list,dname);

Error in musa.driver (line 590)

oo_recursive_=dynare_estimation(var_list_);

Error in dynare (line 293)

evalin(‘base’,[fname ‘.driver’]) ;

musa.mod (3.8 KB)

daudaquarter.xls (34 KB)

Are you sure that your data-treatment is correct? Your data has to match the corresponding variables of your model. Since you have a log-linearised model this means that your data should also be in logs and have steady state of zero, your data clearly still has a trend and is not stationary.

Have you had a look at Prof. Pfeifers excellent guide for how to use observation equations? If not, you should definitely go through it.

Thank You DoubleBass,

I will log-linearised the model and see the outcome of the result

Your model is already log-lineraised, it is about the way you treat your data. It is not possible to just insert data that you download from some site. It has to match model variables. As an example, in your model output is given as percentage deviations from steady state of output per person, ie a stationary data series, but the data you (most likely) took is overall output which is non-stationary. Thus, you have to treat the data to match your variable.

Read the file and look around the forum, there are plenty of posts about exactly just that

Alright. Thank you, I really appreciate.