Multiple IRFs in one graph

Dear All,

I am trying to generate multiple IRFs on the same graph. I know this topic has been covered but I think the code file I am working with are a bit different. I am trying to generate graphs for the same sets of variables but from different scenarios. So for example, say I have two scenarios, in each of the graphs I would like the irfs from both scenario A and B for each variable.

Hopefully, this is clear from the attached files.

One of the main problems I am having is that I am unable to save the irfs (irf1 and irf2) separately, one keeps replacing the other in my folder.

Many thanks.
transition.mod (11.1 KB)
mult_irf.m (246 Bytes)
run_1.m (3.48 KB)
run.m (3.47 KB)

Please explain the logic of your files, which file I need to run, and what does not work as expected.

Many thanks for you reply Prof. Pfeifer

run and run_1 have the same code in them but apply to two different scenarios. As these two files are currently set up, they run the same mod file, under two different names transition.mod and transition_1.mod because I thought this might help.

run refers to the scenario where pmrI = 1; fcI = 0; ubI = 0; while run_1 is set to pmrI = 1; fcI = 1; ubI = 0;. I want to generate irfs for the set of variables in the transition.mod file under these two scenarios in the same graph for each variable.

I am not sure whether it is necessary to name the files differently. I got to this stage because I tried running the single run file twice but under the two different scenarios and saving the simulation results in oo_.endo_simul as irf1 and irf2 respectively but irf2 would just replace irf1 in my folder so I thought I should try to name the files differently, but this doesn’t seem to have worked.

I attach the other files you would need in a zip file. You would only need to run the run.m and run.1 files to see the irfs I am trying to merge ( Alternatively, you can stick with running the run file but changing fcI from 0 to 1).

The mult_irf file was just my initial attempt to start writing a code that would merge the results.

Many thanks. (26.7 KB)

No, it is not necessary to have separate files. Try using the macro-processor language (e.g. as in What exactly do you mean when you say

but irf2 would just replace irf1 in my folder 

If you are referring to a file on the harddisk, you need to assign a different name for the second file. If you are referring to the Matlab workspace, you need to make sure that you do not have any


commands, i.e. you need to invoke Dynare using the



One of the things I have done is to run dynare under one “scenario” as you put it, and then save the impulse responses for that scenario. They can be found in the workspace window. Once they are saved, you can then run the simulation again under the alternative scenario. Following this, dynare should give you the plots for the impulse responses. You can then import your first set of impulse responses into that workspace and add them to your new graphs. In order to do this, you will have to open the figure editor and “add data” to the figure and select the impulse response from the first simulation that you saved.

Many thanks Prof. Pfeifer and ACL.

I have now been able to save the time series. The problem was having ‘clear’ in the run file. I think I should be able to get the irfs now.

Many thanks

From what I can see, you are plotting transformations of the Dynare IRFs in your mod-files, but your loop uses the original IRFs produced by Dynare. That is inconsistent.

Thank you for the response! Indeed I want to plot the transformations (the percentage deviations from the steady state) of the Dynare IRFs. How should the code be in this case?
I tried by writing

irf1 = -irfs_str_ft;
save irf1;
irf2 = -irfs_atr_ft;
save irf2;
irf3 = -irfs_strmacro_ft;
save irf3;
irf4 = -irfs_atrmacro_ft;

but it seems to be ignored and still using the original IRF’s from Dynare.
Same when I try putting a minus in front of irf2, irf3 and irf4 after the eval-statement, in order to have an expansionary financial shock, nothing changes in the figure…

Within your plots, you are using

That’s not where you saved your transformations.