# How to feed in shocks from m file?

Hi everyone

I don’t know if this was discussed before but I couldn’t find any information on this.

Anyway, I have obtained the shocks from actual historical data. And I am trying to feed the vector of shocks into my mod file.

How am I supposed to go about doing this?

Thanks!

Posterior means of volatility of exogenous disturbances? If yes, here is the solution:

myshocks=xb.oo_.posterior_mean.shocks_std;
myshocksmat=cell2mat(struct2cell(myshocks));

shocks;
// Non-stationary technology growth
var epsilon_muz;
stderr myshocksmat(1);

// Stationary technology
var epsilon_epsilon;
stderr myshocksmat(2);

etc.

end;

What is your ultimate goal, i.e. when you feed in the shocks, what are you trying to compute based on the shocks?

Thank you everyone for your replies.

My objective is actually to feed in the shocks and get the impulse responses of key variables like GDP and inflation. Then I’ll compare them to the actual data to see if my model is a fair representation of past economic shocks.

How can I feed in the shocks from an m-file and simulate the impulse responses?

Thank you.

I see. In this case, you have to manually feed the shock series to the simult_-function. An example is here: github.com/JohannesPfeifer/DSGE_mod/tree/master/RBC_news_shock_model

Hi jpfeifer

Thank you very much for the link.

Do you mean this portion of your code:
// 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)
shock_matrix(1+8,strmatch(‘eps_z_surprise’,M_.exo_names,‘exact’)) = -1; %8 periods later use counteracting shock of -1

Thank you.

Yes, along these lines.