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

Hi,

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
strmatch('eps_z_news',M_.exo_names,'exact')
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.

2 Likes

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!
Best,
Joshua

  1. The anticipation comes from the definition of the shock entering with an 8 period lag:
eps_z_news(-8)
  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?

Thanks
Steve

  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.

Hi,
I wonder if it is possible to obtain the simulated series in response to both shocks simultaneously.

Specifically, the simulation result whereby TFP rises first because of the stochastic shock (here, by 1) then falls in period 9 once the anticipated shock materializes (here, by -0.5 from its value in period 8) .

In fact, I would have thought it was ‘y2’ obtained from the code below…

shock_matrix(1,strmatch(‘eps_z_news’,M_.exo_names,‘exact’)) = 1;
shock_matrix(1+8,strmatch(‘eps_z_surprise’,M_.exo_names,‘exact’)) = -0.5;

y2 = simult_(M_,options_,initial_condition_states,oo_.dr,shock_matrix,1)

Thank you in advance! And looking forward for some replies :smiley:

Yes, that should be the correct way to define a sequence of shocks.

However, that doesn’t seem to be the case, right? The simulated TFP does not shoot up in period 1 following the stochastic TFP shock, but rises by 0.5 in period 9 (showing just the net impact on TFP after the anticipated news shock arrived) instead.
Screenshot 2024-05-31 115841
And that’s why you were referring these irfs to a “pure” TFP news shock.
I wonder if it is possible to obtain the series reflecting effects of both shocks simultaneously.

Or do I just combine the first 8 periods generated from the TFP surprise shock alone with y2 period 9 onwards…(this doesn’t sound right tho).

I am not following. What exactly is the experiment you are trying to do? An anticipated shock in the first period does only increase TFP in the future, not today. That is what’s clearly visible in the figure.

I want to see the impact of both shocks on the economy. In the first period, a positive TFP hits the economy. I would expect the TPF and hence Y etc. to react already. Only once the economy reaches period 9, the anticipated negative news shock materialize, and the TFP falls from 1 (or around 1 ) by -0.5…

But that is an experiment where you have a surprise shock in period 1 and a news shock for period 8.

which I thought is already captured by this shock_matrix, no ?

No, that’s a news shock in period 1 and a surprise in period 9.

OH! You are so RIGHT. Apologize for being reckless. And thank you so much for patiently responding to my queries. I got it now.

On my final question: The solving algorithm of the anticipated shock here is identical to the prefect foresight command, right? Since both make use of the simult_ command. So, essentially, I cannot get the economy in which a stochastic shock hits in the first period, and a policy (anticipated) being implement says on period 8. I wonder if you have any suggestions on how to deal with this.

  1. No, the algorithm is not the same, just the results coincide. The perfect foresight solver does not use the simult_.m file.
  2. You can combine anticipated and surprise shocks. That’s what the example shows.

Right. All clear. Thank you so much.