Page 1 of 1

Plotting of IRFs without running model

PostPosted: Fri Sep 18, 2015 11:53 pm
by dphm
Hi all

Is there a way to plot the IRFs without running the model again?

Because I am trying to compare the IRFs for different sets of parameters and it'll save a lot of computation time if I can find a way to get them without executing the command "dynare (model_name)" over and over again.

Thank you.

Re: Plotting of IRFs without running model

PostPosted: Sat Sep 19, 2015 12:32 am
by dphm
Hi all

With reference to my earlier post, I have an m file that can do the above already but I need something to replace the command "makeirfsecondorder".

The error that appears when I execute that command is "Undefined function for input arguments of type 'struct'."

Thanks.

Re: Plotting of IRFs without running model

PostPosted: Sat Sep 19, 2015 7:59 am
by hodabbbb
You have th values of irf in oo_ irf . Save the results file with a different name. Why don't you put the irfs for all the shocks in a matrix and run them by setting up an m file

Re: Plotting of IRFs without running model

PostPosted: Sat Sep 19, 2015 1:33 pm
by dphm
Hi hodabbbb

Thanks for your quick response!

I have tried plotting using oo_.irfs and it works. But now I realized I'm back to the original problem: how do I get the impulse responses after a change of parameters without having to run the model again?

Thanks.

Re: Plotting of IRFs without running model

PostPosted: Sat Sep 19, 2015 2:03 pm
by hodabbbb
You cannot . That's the job th model does.save results with different names: 1.baseline 2.alternative. then compare

Re: Plotting of IRFs without running model

PostPosted: Sat Sep 19, 2015 3:25 pm
by dphm
Hi hodabbbb

Again, thanks for your quick response.

I actually agree with you that if I were to change the parameters, I have to re-run the model again.

However, I thought I happened to chance upon this m file that can enable me to do simulate the IRFs without having to run the model again. I guess I probably overlooked something.

But either way, thanks for the help!

Re: Plotting of IRFs without running model

PostPosted: Sun Sep 20, 2015 12:00 am
by dphm
Hi hodabbbb

I actually realized that because I'm changing parameters that have nothing to do with the steady state, I don't have to run the model again every time I change that parameter value.

So I can resolve for the new steady state using the following command "[dr_,~,M_,~,oo_] = resol(0,M1_,options1_,oo1_);". Now the thing is how do I get the impulse response functions from this command?

What I have now is I run a loop such that if there is more than one change in the parameter, at the second change, I'll skip the "dynare (my model)" command and just go straight to resolving for the new steady-state.

But now, my problem is how do I get the impulse responses from the new steady-state? Because previously, I can simply do oo_.irfs right? But for this, I definitely can't do just that.

By the way, I think that using oo_.irfs to plot the IRFs might not be so general a way because, correct me if I'm wrong, but let's say your shock comes from epsilon_z, then you gotta execute "plot(oo_.irfs.Y_epsilon_z)" but what if I have multiple shocks at one time? How do I plot the impulse response functions more generally?

Thanks.

Re: Plotting of IRFs without running model

PostPosted: Mon Sep 21, 2015 11:44 am
by jpfeifer
First of all: even if the parameters you change do not affect steady states, they will alter the decision rules and require solving the model again.

What exactly are you trying to do? If we are talking about IRFs from different mod-files, the answer is here: http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=5259. See also http://www.dynare.org/phpBB3/viewtopic.php?f=1&t=5049
If you just want to change a parameter within a mod-file and then generate the IRFs, do
Code: Select all
stoch_simul(irf=x,order=x);
irf_set1=oo_.irfs;
set_param_value('betta',x)
stoch_simul(irf=x,order=x);
irf_set2=oo_.irfs;

and then plot the results directly from the structures. With the set_param_value you can change values of parameters (for standard deviations, use a new shocks-block with the reset option).

For multiple shocks: due to certainty equivalence at first order the IRFs to simultaneous shocks are just the sum of individual IRFs. At higher order, you need to use the simult_ function, see https://github.com/JohannesPfeifer/DSGE_mod/tree/master/RBC_news_shock_model

Re: Plotting of IRFs without running model

PostPosted: Fri Sep 25, 2015 3:33 am
by dphm
Hi jpfeifer

First, thank you for all your responses.

I am now left with this issue out of all 3.

I've actually a way to do it but I encountered this error: Reference to non-existent field 'nstatic'.

The reference to nstatic in my code is from: dr_.nstatic

Could you help explain why I have this error and how I can get round it?

Thank you.

Re: Plotting of IRFs without running model

PostPosted: Fri Sep 25, 2015 6:39 am
by jpfeifer
I am not following where that error appears. nstatic is stored in M_, not in dr (dr also never is dr_).