Predefined shocks in certain periods with 'simult_' - How? (DSGE)


I’d like to use ‘simult_’ to shock the model with a predefined matrix of shockvalues (in this case a vector of random variables, that I also use for another simulation within the same work)
for each exogenoues variable and each period, but I really don’t understand how to use this instruction.
I looked at JPfeifers examplary RBC news shock model (This), but i don’t get the intuition behind that.

FlexEcon.mod (2.1 KB)

Maybe someone can help with that.
Thanks in advance and a nice weekend for you all!

P.S.: At first, I uploaded the wrong file -.- :smiley:

  1. You initialize the shock matrix. It will always be
    shock_matrix = zeros(options_.irf,M_.exo_nbr); %create shock matrix with number of time periods in columns
  2. Then you set the shocks that you want. The row index sets the time period, the column index the 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)

sets a shock of size 1 for the first period (therefore in the first row) for the exogenous variable eps_z_news. The command
is used to find the column in which eps_z_news is stored. So for a different shock, you need to change the name string.


Dear Professor Pfeifer,
I’ve read your code RBC_news_shock_model.mod and have several question if I may ask you:

  1. You claim one shock is anticipated to happen in period 8, while the other shock is a surprise from period 1:8 . But in your code both of them are defined as stochastic shocks, which means they are not anticipated. How could we understand that?

  2. In the last part of your code, you wrote

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

is the “1+8” just means 9 or means [1:8] from period 1 to 8 ? (see the TFP lines below)

In the output figures, “z” remain 0, while TFP increase in period 1, and then drop until period 8, and finally climb back to 0. How could “z” remain 0 while TFP fluctuates?

4.could the two shocks be equivalently combined into one shock like this?:

shock_matrix(1,strmatch(‘eps_z_combined’,M_.exo_names,‘exact’)) = 0;
shock_matrix(2+8,strmatch(‘eps_z_combined’,M_.exo_names,‘exact’)) = -1;

Thanks very much!

  1. The anticipation comes from the definition of the shock entering with an 8 period lag:
  1. That means period 9, i.e. 8 periods later than the first period.
  2. Have a look at the scaling. TFP drops by 1e-16, which is 0 up to numerical precision.
  3. Now, you cannot combine the two into one shock due to the different timing structure shown in 1.

Thank you Professor Pfeifer! :grinning:

I am sorry I am referring to an old thread. But I need to create a user defined shock in my problem. I had two questions about the model posted above by Fimo, if you could kindly clear my doubts.

  1. It seems impulse response graphs will not be produced in the above mentioned model. Is the command stoch_simul doing anything in the model?

  2. Can we do a third order approximation in the above model? If stoch_simul is redundant, then where do we put order=3?


  1. No, you have to graph the IRFs yourself based on the simulated series.
  2. The stoch_simul is needed for the computation of the model decision rules. simult_ relies on it. The order needs to be correct as well.