Stochastic shocks in some periods- Iacoviello 2015

Dear Prof. Jpfeifer,
Thank you for your help in advance.
I am working on Iacoviello 2015 (Financial business cycles). He has a stochastic DSGE model. He has a stochastic shock let’s say as :
x=0.9* x(-1)+eps;
and he says :"I feed into the model a sequence of unexpected shocks to eps, each quarter equal to 0.38 percent of annual GDP, which lasts 12 quarters and causes losses for the banking system to rise from zero to 2.8 percent of GDP after 3 years, before loan losses gradually return to zero."
I would like to know how it is possible to have a stochastic shock for some period and how I can set this shock for example to 0.38 percent of annual GDP?
I appreciate you time and consideration.

I am still waiting for the answer, IS there anybody who knows somthing about this kind of shocks?

The mod-file at
shows how to use the simult_ function to feed a given sequence of shocks into the model. The challenge is to determine the shock size. But you should see the steady state of output Y and should be able to scale the shock size accordingly.

Dear Professor Jpfeifer,
Thank you so much for the reply.
I found also this link that really helps me : [Simulate a model using smoothed shocks).
I have just one more question, I run the Iacoviello’s model (attached here) but unofrtunately I get this error :

[quote]Error using check_model (line 20)
Not enough input arguments.
Error in stoch_simul (line 65)
Error in fbc1 (line 682)
info = stoch_simul(var_list_);
Error in dynare (line 223)
evalin(‘base’,fname) ; [/quote]

Then when I search

 which check_model

it replies :
I installed also the latest unstable version but still the same error. I am wondering if it is a problem in codes or my Dynare.
fbc1.mod (10.6 KB)

Please provide the missing files (like the steady state file)

Thank you for the prompt reply.
All files are attached here.
stoch_simul.m (6.65 KB)
fbc1_steadystate.m (4.54 KB)
fbc1.mod (10.6 KB)

Why are you using an old and modified version of stoch_simul? That explains the incompatibility with recent versions.

yes, you are right. This old version is the problem. Actually It is what Prof. Iacoveillo put in the folder to run. I want to compare my results with his results so I run the .mod file he has provided, without considering the old version of stoch_simul in the folder.
Thank you for your great help.
Now I have my estimation .mod file, and I guess it works well. The acceptance rate is 22.97 . I have two question in accordance to my mod file (I attach here) :

  1. If I add another parameter to estimate , like line 340 or 345 , the model does not work and I have an error. How can I fix it?

[quote]Error using chol
Matrix must be positive definite.
Error in posterior_sampler_initialization (line 84)
d = chol(vv);
Error in posterior_sampler (line 59)[/quote]

  1. in the model check plots, I have red dots that I cannot find why they are there. ( the pic in the attachment).

I appreciate your time and consideration
Sincerely, (55.1 KB)

The red dots are points where the model solution could not be computed. That can be because the steady state could not be computed or the Blanchard-Kahn conditions are not satisfied. That ties in to your second question. As you can see in the mode_check plots, the mode is right at the boundary to the region where the model could be solved. As you do not have an interior solution, the Hessian will not be positive definite. The red dots are parameters for which Dynare could not compute the steady state.

Thank you.
So the way to fixing could be adding external steady state file? or something else should be done?
I added the external steady state, now dynare can solve with “mode_compute=4”, and there is no negativity, but still there is red dots in two plots, this makes a problem in the estimation?

In the unstable version, you can use

to get information on the error code giving rise to the red dots. Sometimes it is BK violations, which are not problematic from a programming perspective (but perhaps from an economic perspective)

Thank you so much Professor Jpfeifer. Your helps always show us the best way.
Have a good day

Dear Professor Jpfeifer,

Considering the topic [Stoch_simul after estimation with MH algorithm uses mode) and your last reply on 05/Nov, is this issue now fixed in unstable version? I mean if we easily use stoch_simul right after estimation, dynare will consider mean instead of mode? or we should change it manually? I use unstable version of " dynare-2016-12-01-win".


Dear Leo,
if the bug list does not state

then the bug has been fixed in the unstable version.

Dear Professor Jpfeifer,
Thank you for the hint. So far I checked, apparently it was fixed.
I am sorry for lots of question I have. I attach my all files here. The problem is still

[quote]Error using chol
Matrix must be positive definite.[/quote]

and the fact dynare cannot find the steady state. I provide an external steady state file, and as I checked manually, for a wide range of parameters it is able to compute the steady state perfectly. I guessed that the problem is my initial parameters value, so as you commented on [The initial value of the likelihood is complex) I used estimated_params_init(use_calibration); end;
but still the problem runs.
I checked the eigenvalues and there is no unit one,however there is an eigenvalue=1.003, so I use diffuse_filter but still nothing is fixed.
I was wondering if there is a solution for this problem?

Ps: Once I ran the codes with mode_compute=6 then I put the posterior mean as the prior mean of the parameters for a new computing with mode_compute=4
Leo (23.9 KB)

Your mode_check-plots tend to look strange, suggesting you did not find the correct mode. There is no reason to use the diffuse filter in your case. There is no unit root. I ran the regular filter with mode_compute=9 and it returned

[code]Fval obtained by the minimization routine (minus the posterior/likelihood)): -339.518149

prior mean mode s.d. prior pstdev

psi_db 0.165 0.0447 NaN gamm 0.1250
psi_dh 0.120 0.0000 NaN gamm 0.1250
psi_k 1.166 1.1289 NaN gamm 0.5000
psi_m 0.173 0.8743 NaN gamm 0.1250
psi_a 0.396 0.2824 NaN gamm 0.1250
psi_h 0.892 0.3710 NaN gamm 0.5000
rho_b 0.219 0.1578 NaN beta 0.1000
rho_m 0.250 0.5014 NaN beta 0.1000
rho_TB 0.925 0.9890 NaN beta 0.1000

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

epsilon_TB_I 0.004 0.0017 NaN invg 0.0250
As you can see

ran to 0, which may be due to the prior with an asymptote at 0.

Thank you so much for running my codes.
Yes your right, I see the 0 mode for psi_dh that is problematic. That is quiet strange, Would you think there is a way to fix this issue?

First of all, estimating such a model on only one observable series is a bit of a stretch. Maybe adding other observables will help. Regardless, you should aim at a prior with an interior peak instead of one with an asymptote. Play around with the variance of the prior.

Dear Professor Jpfeifer,
Many Thanks for your great hint. To add some other observable series,(considering I have only one shock in my model), I used your very informative Guide line “A Guide to Specifying Observation Equations for the
Estimation of DSGE Models”, and I used measurement errors to add 3 other observable series to my estimation. Then I tried to reduce the number of estimated parameters and add one by one (and run estimation after adding each parameter) to find which one causes the problem. I found the problem comes from “rho_b” (inertia for capital constraint) and “rho_m”(inertia for collateral constraint). Then as your comment, I changed their variances to see in which range, estimation works and Dynare can find the steady state and now the model works. I have 2 question:

  1. In order to find the prior’s mean and st error, At first, I used mode_compute=6 and I put the estimated mean and st error as the prior’s mean and st error for my new estimation with mode_compute=4, Is this way ok or this causes problem for estimation?
  2. after estimating model with mode_compute=4, I have 2 parameters that their posterior are very close to their priors, does it show something wrong? (Considering a line in the guideline which says if posterior is close to prior that shows a mistake)
    I attache my .mod file here.
  1. Your prior is your prior before seeing the data. What you describe is problematic, because it will result in wrong inference. You should simply choose a prior that looks sensible, i.e. has a single peak around e.g. 1 percent standard deviation and is somewhat diffuse.
  2. That simply means your data is not very informative. If the identification command does not complain, this should be fine.