Q: combining IRFs into subplotted figures & iterating?

Use

clear,clc

% Run and collect dynare outputs

dynare tank_cw;
irf1 = oo_.irfs;
save tank_cw_results.mat irf1;

dynare tankcw1;
irf2 = oo_.irfs;
save tankcw1_results.mat irf2;

ending_cell={'_eps'};

for ii=1:length(ending_cell)
    HOR=1:options_.irf;
    var={'n', 'nW', 'w', 'c', 'cC', 'cW', 'rn', 'r', 'pi', 'b', 'bC', 'bW', 't', 'g', 'd', 'csl', 'chl', 'bsl', 'bhl', 'ls'}; % variables to be plotted as called in Dynare
    fig(ii)= figure('Name',['Shock to',sprintf(ending_cell{1,ii})],'NumberTitle','off');
    % plot the model variables 
    for jj=1:length(var)
        subplot(5,5,jj)
        hold on
        plot(HOR,irf2.([var{1,jj},ending_cell{1,ii}]),HOR,irf1.([var{1,jj},ending_cell{1,ii}]),'LineWidth',1.3);      
        xlim([1 options_.irf]);
        hline = refline(0, 0);
        title([var{1,jj}] )
    end
    
    legend('Model1', 'Model2', 'AutoUpdate','off')
   
end
1 Like