# DSGE modelling with endogeneous shocks

Dear all, i’m doing the replication of the paper “Shadow Banking & Financial Regulation” by Fevé 2019. The authors have defined some equations inside the model such that three shocks are endogeneous: epsilonm (shock to labour market), epsilon (shock to loans) and epsilond (shock to household deposits).

As consequence of that, i could simulate the model, as you can see in the dynare code, but i couldn’t estimate the parameters on the bayesian mode.

My question are:

1. Dynare offers or not an alternative method to estimate a (bayesian) dsge with endogeneous shocks?
2. The authors were fitting the bayesian model with dynare following the parameters described in table 2 and 3 of the paper; but i don’t know if they were assuming the endogeneous shocks as state variables. On the stoch simulation i had a singularity problem, that could be the problem for the bayesian estimation?

I appreciate any advice to manage this kind of endogeneous structures. Thanks a lot!

test.mod (7.0 KB)

``````>> dynare test.mod
Starting Dynare (version 5.4).
Calling Dynare with arguments: none
Starting preprocessing of the model file ...
Found 26 equation(s).
Evaluating expressions...done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 1).
Processing outputs ...
done
Preprocessing completed.

MODEL_DIAGNOSTICS:  The Jacobian of the static model is singular
MODEL_DIAGNOSTICS:  there is 1 colinear relationships between the variables and the equations
Colinear variables:
x
f
k
h
w
ll
ii
s
rk
c
aabs
n
d
pi_b
pi_s
costx
ra
rd
Colinear equations
2     3     4     8     9    10    17    18    19    20

MODEL_DIAGNOSTICS:  The singularity seems to be (partly) caused by the presence of a unit root
MODEL_DIAGNOSTICS:  as the absolute value of one eigenvalue is in the range of +-1e-6 to 1.
MODEL_DIAGNOSTICS:  If the model is actually supposed to feature unit root behavior, such a warning is expected,
MODEL_DIAGNOSTICS:  but you should nevertheless check whether there is an additional singularity problem.
MODEL_DIAGNOSTICS:  The presence of a singularity problem typically indicates that there is one
MODEL_DIAGNOSTICS:  redundant equation entered in the model block, while another non-redundant equation
MODEL_DIAGNOSTICS:  is missing. The problem often derives from Walras Law.

Residuals of the static equations:

Equation number 1 : 0 : f
Equation number 2 : 0 : 2
Equation number 3 : 0 : 3
Equation number 4 : 0 : k
Equation number 5 : 0 : 5
Equation number 6 : 0 : x
Equation number 7 : 0 : costx
Equation number 8 : 0 : pi_b
Equation number 9 : 0 : 9
Equation number 10 : 0 : pi_s
Equation number 11 : 0 : lambda
Equation number 12 : 0 : 12
Equation number 13 : 0 : 13
Equation number 14 : 0 : 14
Equation number 15 : 0 : 15
Equation number 16 : 3.687e-07 : 16
Equation number 17 : 0 : 17
Equation number 18 : 0 : 18
Equation number 19 : 0 : q
Equation number 20 : 0 : 20
Equation number 21 : 0 : 21
Equation number 22 : 0 : 22
Equation number 23 : 0 : 23
Equation number 24 : 0 : 24
Equation number 25 : 0 : 25
Equation number 26 : 0 : epsilona

MODEL SUMMARY

Number of variables:         26
Number of stochastic shocks: 6
Number of state variables:   14
Number of jumpers:           7
Number of static variables:  9

MATRIX OF COVARIANCE OF EXOGENOUS SHOCKS
Variables      shockz    shockl    shocka    shockd    shockm    shocki
shockz       0.000100  0.000000  0.000000  0.000000  0.000000  0.000000
shockl       0.000000  0.000100  0.000000  0.000000  0.000000  0.000000
shocka       0.000000  0.000000  0.000100  0.000000  0.000000  0.000000
shockd       0.000000  0.000000  0.000000  0.000100  0.000000  0.000000
shockm       0.000000  0.000000  0.000000  0.000000  0.000100  0.000000
shocki       0.000000  0.000000  0.000000  0.000000  0.000000  0.000100

POLICY AND TRANSITION FUNCTIONS
c               f               k               h              rd              rk              ra
Constant                    0.325569        0.439243        1.351351        0.250000               0        0.108563               0
k(-1)                       0.068726        0.112429        1.030074        0.003304        0.016834       -0.052549        0.220324
ll(-1)                      0.069706       -0.023764       -0.158466       -0.020309       -0.087833       -0.005873       -0.354305
epsilonz(-1)                0.065460        0.290494        0.180771        0.023030        0.031512        0.071799        0.018449
epsilonl(-1)                0.107207       -0.016371       -0.412085       -0.013990       -0.558934       -0.004046       -0.529156
epsilona(-1)                       0               0               0               0               0               0        0.600000
epsilond(-1)               -0.049344        0.014229       -0.109943        0.012160        0.011487        0.003517        0.019431
epsiloni(-1)               -0.112506        0.025577        0.056617        0.021858        0.287450        0.006322        0.283359
h(-1)                       0.174384        0.773877        0.481573        0.661353        0.083947        0.191272        0.049148
epsilonm(-1)               -0.002207       -0.005789       -0.002777       -0.004947       -0.001477       -0.001431       -0.001276
shockz                      0.109099        0.484157        0.301284        0.038384        0.052519        0.119664        0.030748
shockl                      0.014111       -0.002155       -0.054240       -0.001841       -0.073569       -0.000533       -0.069649
shocka                             0               0               0               0               0               0        1.000000
shockd                     -0.007908        0.002280       -0.017620        0.001949        0.001841        0.000564        0.003114
shockm                     -0.042032       -0.110264       -0.052888       -0.094231       -0.028129       -0.027253       -0.024307
shocki                     -0.187510        0.042629        0.094361        0.036430        0.479083        0.010536        0.472265

MOMENTS OF SIMULATED VARIABLES
VARIABLE              MEAN       STD. DEV.        VARIANCE        SKEWNESS        KURTOSIS
c                 0.325546        0.003947        0.000016        0.208570       -0.132038
f                 0.439234        0.008084        0.000065        0.094046       -0.331300
k                 1.351108        0.017536        0.000308       -0.074628       -0.385568
h                 0.249734        0.002471        0.000006       -0.052040       -0.525197
rd               -0.000083        0.006163        0.000038        0.016972       -0.214100
rk                0.108584        0.001777        0.000003        0.034912       -0.063291
ra                0.001719        0.013117        0.000172        0.022846       -0.196848

CORRELATION OF SIMULATED VARIABLES
VARIABLE          c        f        k        h       rd       rk       ra
c            1.0000   0.6544   0.7192   0.3411  -0.5595   0.1873  -0.2615
f            0.6544   1.0000   0.6954   0.6786   0.1647   0.7262   0.0276
k            0.7192   0.6954   1.0000   0.4213   0.0698   0.0133  -0.0332
h            0.3411   0.6786   0.4213   1.0000   0.2950   0.5475   0.0976
rd          -0.5595   0.1647   0.0698   0.2950   1.0000   0.2185   0.3772
rk           0.1873   0.7262   0.0133   0.5475   0.2185   1.0000   0.0871
ra          -0.2615   0.0276  -0.0332   0.0976   0.3772   0.0871   1.0000

AUTOCORRELATION OF SIMULATED VARIABLES
VARIABLE          1        2        3        4        5
c            0.7913   0.6353   0.5106   0.4003   0.3128
f            0.7414   0.5293   0.3680   0.2393   0.2107
k            0.9643   0.8910   0.7984   0.7010   0.6075
h            0.8683   0.6590   0.4576   0.2940   0.1873
rd           0.6096   0.3834   0.2082   0.1112   0.0161
rk           0.6171   0.3273   0.1240  -0.0203  -0.0091
ra           0.5951   0.2615   0.1179   0.0458  -0.0280

VARIANCE DECOMPOSITION SIMULATING ONE SHOCK AT A TIME (in percent)
shockz            shockl            shocka            shockd            shockm            shocki  Tot. lin. contr.
c                52.35              0.82              0.00              0.11             12.91             31.16             97.35
f                79.44              0.09              0.00              0.00             12.40              2.99             94.92
k                67.77              2.76              0.00              0.11             14.64             11.76             97.03
h                12.25              0.20              0.00              0.06             71.14             11.22             94.87
rd                2.94              2.57              0.00              0.01              0.68             92.88             99.08
rk               81.88              1.04              0.00              0.07              9.34              2.83             95.15
ra                1.98              0.48             86.50              0.01              0.42             19.27            108.66
Note: numbers do not add up to 100 due to non-zero correlation of simulated shocks in small samples

Total computing time : 0h00m16s
``````

That looks like a standard DSGE model. The “endogenous shocks” are structurally just exogenous processes. What is the problem you are experiencing during estimation? As the model has a unit root, you will need the `diffuse_filter` option.

Prof. Pfeifer, thanks. You’re right about the endogeneous shocks definition, the relations aren’t among shocks. Using the diffuse filter i got a preliminar output on the bayesian estimation; however, i could’nt get a correct characterization of the posterior variance shocks and the variance decomposition, because of a cointegration on the endogeneous variables. I used the observables variables defined by the authors: sb_obs, lev_obs y spread_obs. I appreciate any advice, thanks a lot. i attach the mod file and data file.

BaseFiltro.xlsx (37.1 KB)
dsge_Feve_model_bayes.mod (7.5 KB)

dynare dsge_Feve_model_bayes.mod
Starting Dynare (version 5.4).
Calling Dynare with arguments: none
Starting preprocessing of the model file …
Found 29 equation(s).
Evaluating expressions…done
Computing static model derivatives (order 1).
Computing dynamic model derivatives (order 1).
Processing outputs …
done
Preprocessing completed.

DYNARE_SOLVE (solve_algo=2|4|12): number of blocks = 12
DYNARE_SOLVE (solve_algo=2|4|12): solving block 12 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 12 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 11 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 11 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 10 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 10 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 9 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 9 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 8 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 8 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 7 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 7 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 6 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 5 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 of size 18.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 4 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 3 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 2 with trust_region routine.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 of size 1.
DYNARE_SOLVE (solve_algo=2|4|12): solving block 1 with trust_region routine.
MODEL_DIAGNOSTICS: No obvious problems with this mod-file were detected.

EIGENVALUES:
Modulus Real Imaginary

``````           0                0                0
9.36e-17        -9.36e-17                0
1.445e-16        1.445e-16                0
1.588e-16       -1.588e-16                0
4.658e-16        4.658e-16                0
2.954e-15       -2.954e-15                0
0.6              0.6                0
0.6              0.6                0
0.6              0.6                0
0.6              0.6                0
0.6              0.6                0
0.6              0.6                0
0.7355           0.7355                0
0.7771           0.7771                0
1                1                0
1.375            1.371           0.1043
1.375            1.371          -0.1043
5.348           -5.348                0
1.324e+12        1.324e+12                0
5.718e+16       -5.718e+16                0
5.443e+33        5.443e+33                0
Inf             -Inf                0
``````

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

The rank condition is verified.

x 0.121597
f 0.459663
k 1.53264
h 0.251278
w 1.21832
ll 1.05826
ii 0.038316
s 0.474376
rk 0.100172
c 0.338627
q 1
aabs 0.475613
n 0.227423
d 1.30645
pi_b 0.00695928
pi_s 0.0254307
costx -0.00303531
ra 0.0189079
rd 7.77104e-05
epsilonz 1
epsilonl 0.0789742
epsilona 0
epsilond 0.0961599
epsilonm 11.4277
epsiloni 1
lambda 0.975
sb_obs 0.309516
lev_obs 4.65328

Residuals of the static equations:

Equation number 1 : 0 : f
Equation number 2 : 0 : 2
Equation number 3 : -1.074e-07 : 3
Equation number 4 : 0 : k
Equation number 5 : 0 : 5
Equation number 6 : 0 : x
Equation number 7 : 0 : costx
Equation number 8 : 4.9958e-07 : pi_b
Equation number 9 : 0 : 9
Equation number 10 : 3.2014e-07 : pi_s
Equation number 11 : 0 : lambda
Equation number 12 : 0 : 12
Equation number 13 : -2.6889e-06 : 13
Equation number 14 : 2.7543e-06 : 14
Equation number 15 : 0 : 15
Equation number 16 : 6.5234e-08 : 16
Equation number 17 : 0 : 17
Equation number 18 : 0 : 18
Equation number 19 : 0 : q
Equation number 20 : -7.6395e-07 : 20
Equation number 21 : 0 : 21
Equation number 22 : 0 : 22
Equation number 23 : 0 : 23
Equation number 24 : 0 : 24
Equation number 25 : 0 : 25
Equation number 26 : 0 : epsilona
Equation number 27 : 0 : sb_obs
Equation number 28 : 0 : lev_obs
Equation number 29 : 0 : spread_obs

Initial value of the log posterior (or likelihood): -60530.5228

# ========================================================== Change in the posterior covariance matrix = 0.013225. Change in the posterior mean = 0.35937. Current mode = -713.9813 Mode improvement = 276.5405 New value of jscale = 0.020213

Optimal value of the scale parameter = 0.020213

Final value of minus the log posterior (or likelihood):-713.981253

MODE CHECK

Fval obtained by the minimization routine (minus the posterior/likelihood)): -713.981253

RESULTS FROM POSTERIOR ESTIMATION
parameters
prior mean mode s.d. prior pstdev

phi 0.5000 0.6248 0.0115 beta 0.1000
gamma 0.2000 0.0015 0.0154 gamm 0.1000
theta2 0.0300 0.0392 0.0015 gamm 0.0200
rhoz 0.5000 0.0927 0.0168 beta 0.2000
rhoi 0.5000 0.8481 0.0292 beta 0.2000
rhom 0.5000 0.7769 0.0281 beta 0.2000
rhol 0.5000 0.8362 0.0293 beta 0.2000
rhoa 0.5000 0.0493 0.0673 beta 0.2000
rhod 0.5000 0.9906 0.0071 beta 0.2000

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

shockz 0.0100 0.0619 0.0083 invg Inf
shocka 0.0100 0.0046 0.0093 invg Inf
shockl 0.0100 0.0250 0.0192 invg Inf
shockd 0.0100 1.0392 0.1254 invg Inf
shockm 0.0100 0.0390 0.0162 invg Inf
shocki 0.0100 0.0065 0.0011 invg Inf

Log data density [Laplace approximation] is 655.118496.

Estimation::mcmc: Multiple chains mode.
Estimation::mcmc: Searching for initial values…
Estimation::mcmc: Initial values found!

Estimation::mcmc: Write details about the MCMC… Ok!
Estimation::mcmc: Details about the MCMC are available in dsge_Feve_model_bayes/metropolis\dsge_Feve_model_bayes_mh_history_0.mat

Estimation::mcmc: Number of mh files: 1 per block.
Estimation::mcmc: Total number of generated files: 2.
Estimation::mcmc: Total number of iterations: 10000.
Estimation::mcmc: Current acceptance ratio per chain:
Chain 1: 24.68%
Chain 2: 21.25%
Estimation::mcmc: Total number of MH draws per chain: 10000.
Estimation::mcmc: Total number of generated MH files: 1.
Estimation::mcmc: I’ll use mh-files 1 to 1.
Estimation::mcmc: In MH-file number 1 I’ll start at line 5001.
Estimation::mcmc: Finally I keep 5000 draws per chain.

MCMC Inefficiency factors per block
Parameter Block 1 Block 2
SE_shockz 601.360 527.829
SE_shocka 415.396 245.943
SE_shockl 361.571 386.998
SE_shockd 470.299 605.152
SE_shockm 560.005 547.241
SE_shocki 616.262 584.401
phi 406.430 338.243
gamma 527.124 523.473
theta2 559.882 582.831
rhoz 489.733 548.806
rhoi 518.642 611.690
rhom 464.017 441.894
rhol 420.451 605.912
rhoa 421.322 487.429
rhod 559.612 438.374

Estimation::mcmc::diagnostics: Univariate convergence diagnostic, Brooks and Gelman (1998):
Parameter 1… Done!
Parameter 2… Done!
Parameter 3… Done!
Parameter 4… Done!
Parameter 5… Done!
Parameter 6… Done!
Parameter 7… Done!
Parameter 8… Done!
Parameter 9… Done!
Parameter 10… Done!
Parameter 11… Done!
Parameter 12… Done!
Parameter 13… Done!
Parameter 14… Done!
Parameter 15… Done!

Estimation::marginal density: I’m computing the posterior mean and covariance… Done!
Estimation::marginal density: I’m computing the posterior log marginal density (modified harmonic mean)… Done!

ESTIMATION RESULTS

Log data density is 620.757742.

parameters
prior mean post. mean 90% HPD interval prior pstdev

phi 0.500 0.6222 0.6169 0.6274 beta 0.1000
gamma 0.200 0.0033 0.0019 0.0046 gamm 0.1000
theta2 0.030 0.0402 0.0389 0.0414 gamm 0.0200
rhoz 0.500 0.0976 0.0842 0.1116 beta 0.2000
rhoi 0.500 0.8377 0.8173 0.8569 beta 0.2000
rhom 0.500 0.7787 0.7737 0.7854 beta 0.2000
rhol 0.500 0.8392 0.8245 0.8512 beta 0.2000
rhoa 0.500 0.0475 0.0187 0.0729 beta 0.2000
rhod 0.500 0.9889 0.9846 0.9926 beta 0.2000

standard deviation of shocks
prior mean post. mean 90% HPD interval prior pstdev

shockz 0.010 0.0664 0.0610 0.0730 invg Inf
shocka 0.010 0.0054 0.0037 0.0076 invg Inf
shockl 0.010 0.0249 0.0199 0.0296 invg Inf
shockd 0.010 1.0736 0.9554 1.1564 invg Inf
shockm 0.010 0.0472 0.0342 0.0571 invg Inf
shocki 0.010 0.0066 0.0059 0.0072 invg Inf
Estimation::mcmc: Posterior (dsge) IRFs…
Estimation::mcmc: Posterior IRFs, done!
Estimation::compute_moments_varendo: I’m computing endogenous moments (this may take a while)…

dsge_simulated_theoretical_variance_decomposition:: All requested endogenous variables have a unit root and thus infinite variance.
dsge_simulated_theoretical_variance_decomposition:: No decomposition is performed.

Posterior mean variance decomposition (in percent)
shockz shockl shocka shockd shockm shocki
sb_obs NaN NaN NaN NaN NaN NaN
lev_obs NaN NaN NaN NaN NaN NaN
spread_obs NaN NaN NaN NaN NaN NaN

Done!

DsgeSmoother: Switching to univariate filter. This is usually due to co-integration in diffuse filter,
otherwise it may be a sign of stochastic singularity.
Estimation::mcmc: Forecasted variables (mean)
Estimation::mcmc: Forecasted variables (mean), done!
Estimation::mcmc: Forecasted variables (point)
Estimation::mcmc: Forecasted variables (point), done!

DsgeSmoother: Switching to univariate filter. This is usually due to co-integration in diffuse filter,
otherwise it may be a sign of stochastic singularity.
Total computing time : 1h02m16s
Note: warning(s) encountered in MATLAB/Octave code