Page 1 of 1

How to feed in shocks from m file?

PostPosted: Fri Sep 25, 2015 3:41 am
by dphm
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!

Re: How to feed in shocks from m file?

PostPosted: Sun Sep 27, 2015 6:30 am
by econ86
Posterior means of volatility of exogenous disturbances? If yes, here is the solution:

xb=load ('name_of_your_results_matrix.mat');
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;

Re: How to feed in shocks from m file?

PostPosted: Sun Sep 27, 2015 8:16 am
by jpfeifer
What is your ultimate goal, i.e. when you feed in the shocks, what are you trying to compute based on the shocks?

Re: How to feed in shocks from m file?

PostPosted: Sun Sep 27, 2015 9:29 am
by dphm
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.

Re: How to feed in shocks from m file?

PostPosted: Sun Sep 27, 2015 9:48 am
by jpfeifer
I see. In this case, you have to manually feed the shock series to the simult_-function. An example is here: https://github.com/JohannesPfeifer/DSGE_mod/tree/master/RBC_news_shock_model

Re: How to feed in shocks from m file?

PostPosted: Sun Sep 27, 2015 10:14 am
by dphm
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.

Re: How to feed in shocks from m file?

PostPosted: Thu Oct 01, 2015 9:24 pm
by jpfeifer
Yes, along these lines.