Plotting multiple IRFs - many endogenous vars


I understand that if I want to plot multiple IRFs, I would need to do this on MATLAB. I have generated the code for my model and generated code for my variables from steady state (because I had about 52 endogenous variables but only needed 12 for analysis). I therefore have the following code for them after stoch_simul as plots from deviations from steady state, for example for one variable I have:

yepos = strmatch('ye',M_.endo_names,'exact');


figure('Name','Baseline impulse responses to copper price shock');



axis tight;

title('Tradeable sector output');

I wanted to please find out if I would be able to transfer these plots onto MATLAB to plot multiple IRFs and if there is any code that would help me with this as I am struggling

Thank you!

Hi m6882,

see my answer to a smiliar question a couple of days ago.
If you only want to plot 12 endogenous variables, the easy way is just to incorporate those in the stoch_simul command and not the others. Something like: stoch_simul()1 2 ... 12


Thank you so much! Using this code I was able to do subplots:

dynare a.mod;
irf1 = oo_.irfs;
save a.mat irf1;

dynare b.mod;
irf2 = oo_.irfs;
save b.mat irf2;

%'y', 'dp', 'cs', 'cb', 'h', 'hs', 'r', 'qh', 'qz'
for ii=1:length(ending_cell)
    var={'y', 'dp', 'cs', 'cb', 'h', 'hs', 'r', 'qh', 'qz'};
    for jj=1:length(var)
        eval(['irf1.' var{1,jj},ending_cell{1,ii}]);
        eval(['irf2.' var{1,jj},ending_cell{1,ii}]);
        hold on
        plot(HOR,[eval(['irf1.' var{1,jj},ending_cell{1,ii}])],'-b',HOR,[eval(['irf2.' var{1,jj},ending_cell{1,ii}])],'--r','LineWidth',2) ;
        title([var{1,jj}] )

I wanted to find out on a few things:

  1. is there any way I could compute deviations from steady state?
  2. how can I change my labels automatically (i.e. is there any additional code I can use for this)?
  3. is there any code I could use to label my x and y axes systematically?
  4. I wanted to have boxes/lines within the IRFs, just o be neat - is there any way I could do this?

Thank you

Glad it helped.
Ad 1: Depends on what kind of model you have, if it is log-linearized it already shows percentage deviations from steady state for instance.
Ad 2 - 4: Those questions are Matlab related so I would suggest you google exactly how you want your plots to look like and you will most certainly find what you are looking for.