IRF-Plotting-Guide for Beginners

Hey,
first of all, I hope you’ll excuse me, if this was posted somewhere already:
I am desperately looking for a user guide for plotting (subplotting) IRF’s and for creating figures. I am a beginner and the Matlab user-guide seems to be not specific enough for a dynare environment.

Additionally, I would like to understand the error messages that I’m getting in the code:

Index in position 2 exceeds array bounds. Index must not exceed 15.

Error in mo_02.driver (line 345)
subplot(3,3,1), plot(0:1:15,Impa(10,1:16),'r--','LineWidth',2)

Error in dynare (line 281)
    evalin('base',[fname '.driver']);

Thanks!

Hi diserable,

what exactly is it that you are trying to do. It is difficult to see that from the error message alone. The thing is that (advanced) plotting is not done in Dynare but after running your mod-file in Matlab. For this you save your results and then call them again to plot.
Here is a sample code, which is for comparing to models but it should give you an idea about how it is done.
If you have a specific question, feel free to come back.

1 Like


These are the plots that I’m trying to reproduce.

This is my code:
mo_02.mod (3.7 KB)

And that is the error message that I get:

Index in position 2 exceeds array bounds. Index must not exceed 15.

Error in mo_02.driver (line 343)
subplot(3,3,1), plot(0:1:15,Impa(10,1:16),'r--','LineWidth',2)

Error in dynare (line 281)
    evalin('base',[fname '.driver']);
 

You set irf=15, but are trying to plot 16 periods.

1 Like

You are right. So I changed irf to 16 and now get the following error message:

Unable to perform assignment because the size of the left side is 1-by-15 and the size of the
right side is 16-by-1.

Error in mo_02.driver (line 332)
Impa(myloop0,:)=n_e;

Error in dynare (line 281)
    evalin('base',[fname '.driver']);

All vectors plotted in Matlab have to have the same length, and it does not matter if you start them from zero or one, the length is crucial.

Try this:
mo_02.mod (3.7 KB)

1 Like

Oh, I see. This looks much better already. Thank you @DoubleBass!
Just one more question: How can I change a parameter for the blue line? I want set \lambda = 0 and compare it with the red line where \lambda = 0.5.

By saving the results in oo_ and then using set_param_value to alter the parameter. See e.g. Q: combining IRFs into subplotted figures & iterating?

1 Like