# Dynare issues and DSGE modelling

**URL:** <https://forum.dynare.org/t/dynare-issues-and-dsge-modelling/24908>\
**Category:** Replication Attempts\
**Created:** [5 January 2024 20:24 UTC](https://forum.dynare.org/t/dynare-issues-and-dsge-modelling/24908 "2024-01-05T20:24:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriellaneilon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/c68b51/32.png) [@gabriellaneilon](https://forum.dynare.org/u/gabriellaneilon)\
**Post date:** [5 January 2024 20:24 UTC](https://forum.dynare.org/t/dynare-issues-and-dsge-modelling/24908/1 "2024-01-05T20:24:38Z")

</div>

Hello, I am currently replicating the following for my Advanced Time Series Master’s project: to estimate the DSGE model(s) in Ch4 in the Handbook of Bayesian  
Econometrics by Marco Del Negro and Fran Shordfeide (2010). With the following instructions:  Estimate the model(s).  
 Report your estimation results and discuss.  
– Report steady states of the model.  
– Prior distribution and posterior estimates for all models (in one table).  
– MCMC acceptance rates.  
– IRFs.  
1.2 Evaluation  
Report and discuss the followings:  
 Predictive checks: Prior check and mode check.  
 Posterior-odd ratio.  
 DSGE vs VAR (optional).  
 Figure of posterior distribution.  
 MCMC.

I have already successfully simulated the model, but as soon as I incorporate my data I run into issues. I have even differenced my variables and tried again but no luck. I obtained Euro Area data Here is my code: (as well as the transformations I also tried)  
data=readtimetable(“Data.xlsx”)

data=data(54:end, 1:end)

Y\_ldiff = diff(log(data.Y));  
C\_ldiff=diff(log(data.C));  
H\_ldiff= diff(log(data.H));  
I\_ldiff=diff(log(data.I));  
i\_diff = diff(data.i);

Data\_diff = array2timetable([Y\_ldiff C\_ldiff H\_ldiff I\_ldiff i\_diff],…  
‘RowTimes’,data.Date(2:end),‘VariableNames’,{‘ydiff’ ‘C\_ldiff’ ‘hdiff’ ‘I\_ldiff’ ‘i\_diff’});

//----------------------------------------------------------------

// 1. Endogenous variables

//----------------------------------------------------------------

var

Y

C

I

K

H

W

R

a

B

A

ydiff

hdiff;

//----------------------------------------------------------------

// 2. Exogenous variables (3)

//----------------------------------------------------------------

varexo

e\_a

e\_b;

//----------------------------------------------------------------

// 3. Parameters

//----------------------------------------------------------------

parameters

B\_star

alpha //capital output share// capital elasticity in the production function

beta //household subjective discount factor

gamma // DETERMINISTIC TREND COMPONENT OF TECHNOLOGY GROWTH

rho\_a // persistence of tech progress

rho\_b

sigma\_a

sigma\_b

delta //depreciation rate

nu //the aggregate labor supply elasticity

tau; //

B\_star=1;

alpha=0.66;

rho\_a = 0.01;

rho\_b= 0.8;

tau = 0.025;

beta = 0.99;

delta = 0.025;

nu = 2;

gamma = 1.49;

sigma\_a= 0.01;

sigma\_b= 0.01;

//----------------------------------------------------------------

// 4. Model

//----------------------------------------------------------------

model;

1/C=beta\*(1/C(+1))_exp(-a(+1))_(R(+1) + (1-delta));

1/C_W=1/B_(H/B)^(1/nu);

W=alpha\*(Y/H);

R=(1-alpha)\*(Y/K)\*exp(a);

Y=H^alpha\*(K\*exp(-a))^(1-alpha);

Y=C+I;

K=(1-delta)\*K(-1)\*exp(-a)+I(-1);

a=ln(gamma)+(rho\_a-1)_ln(A(-1))+sigma\_a_e\_a;

ln(A)=rho\_a_ln(A(-1))+sigma\_a_e\_a;

ln(B)=(1-rho\_b)_log(B\_star)+rho\_b_ln(B(-1))+sigma\_b\*e\_b;

ydiff=gamma+Y-Y(-1)+a;

hdiff=H-H(-1);

end;

initval;

Y=1;

C=0.6696;

I=0.3304;

K=0.95585;

H=0.5;

W=1.32;

R=0.53;

a=0.4;

B=1;

A=1;

end;

//----------------------------------------------------------------

// 5. Shocks

//----------------------------------------------------------------

shocks;

var e\_a; stderr 0.01;

var e\_b; stderr 0.01;

end;

//----------------------------------------------------------------

// 6. The Steady State Model

//----------------------------------------------------------------

steady;

check;

//----------------------------------------------------------------

// 7. Estimation of Parameters

//----------------------------------------------------------------

estimated\_params;

alpha, 0.66,-0.000000000000001,0.999999999999,BETA\_PDF,0.66,0.02;

gamma,0.003,-10000,99999999999,NORMAL\_PDF,0,.1;

nu,0.4,-1E-15,999999999999,GAMMA\_PDF,2,1;

rho\_a,0.95,-1E-15,0.999999999999,BETA\_PDF,0.95,0.02;

rho\_b,0.98,-1E-15,0.999999999999,BETA\_PDF,0.8,0.1;

stderr e\_a,0.01,-1E-15,999999999999,INV\_GAMMA\_PDF,0.015,4;

stderr e\_b,0.007,-1E-15,999999999999,INV\_GAMMA\_PDF,0.01,4;

end;

varobs ydiff hdiff;

estimation(datafile=DSGE\_data\_diff,xls\_sheet=DSGE\_data\_diff,nobs=114,mh\_replic=1000,mh\_jscale=0.5);

And my output/error that I get:

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.4).  
Starting preprocessing of the model file …  
Found 12 equation(s).  
Evaluating expressions…done  
Computing static model derivatives:

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

STEADY-STATE RESULTS:

Y 0.78787  
C 0.5276  
I 0.26027  
K 0.753013  
H 0.990366  
W 0.525053  
R 0.530051  
a 0.398776  
B 1  
A 1  
ydiff 1.88878  
hdiff 0

EIGENVALUES:  
Modulus Real Imaginary

```
           0 -0 0
   1.691e-18 -1.691e-18 0
   2.435e-16 2.435e-16 0
        0.01 0.01 0
      0.6271 0.6271 0
         0.8 0.8 0
       1.611 1.611 0
   3.515e+16 3.515e+16 0
         Inf -Inf 0

```

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

The rank condition is verified.

You did not declare endogenous variables after the estimation/calib\_smoother command.  
Error using load\_mat\_file\_data\_legacy  
makedataset: The variable(s) ydiff, hdiff listed in varobs are not contained in the dataset

Error in makedataset (line 128)  
DynareDataset = load\_mat\_file\_data\_legacy(datafile, DynareOptions.varobs);

Error in dynare\_estimation\_init (line 538)  
[dataset\_, dataset\_info, newdatainterfaceflag] = makedataset(options\_, options\_.dsge\_var\*options\_.dsge\_varlag, gsa\_flag);

Error in dynare\_estimation\_1 (line 116)  
dynare\_estimation\_init(var\_list\_, dname, , M\_, options\_, oo\_, estim\_params\_, bayestopt\_);

Error in dynare\_estimation (line 105)  
dynare\_estimation\_1(var\_list,dname);

Error in ModifiedDSGEmodels (line 240)  
oo\_recursive\_=dynare\_estimation(var\_list\_);

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

---

<div class="post-metadata">

**Author:** ![Jingjing](https://forum.dynare.org/letter_avatar_proxy/v4/letter/j/a88e57/32.png) [@Jingjing](https://forum.dynare.org/u/Jingjing)\
**Post date:** [7 January 2024 13:33 UTC](https://forum.dynare.org/t/dynare-issues-and-dsge-modelling/24908/2 "2024-01-07T13:33:17Z")

</div>

Since you did not upload `Data.xlsx`, so I could not run the compelete the file.  
But from the erros: `You did not declare endogenous variables after the estimation/calib_smoother command. Error using load_mat_file_data_legacy makedataset: The variable(s) ydiff, hdiff listed in varobs are not contained in the dataset`

There are something wrong in `varobs ydiff hdiff bolck and estimation block` . We get the `Y_Idiff C_Idiff ...` from the data, so `ydiff and hdiff` are not consistent.

---

<div class="post-metadata">

**Author:** ![gabriellaneilon](https://forum.dynare.org/letter_avatar_proxy/v4/letter/g/c68b51/32.png) [@gabriellaneilon](https://forum.dynare.org/u/gabriellaneilon)\
**Post date:** [8 January 2024 13:30 UTC](https://forum.dynare.org/t/dynare-issues-and-dsge-modelling/24908/3 "2024-01-08T13:30:11Z")

</div>

Hello! Thank you for replying! I have figured out what went wrong and my model is now running smoothly!
