% //********************************************************************************************
% // A Financial accelerator model
% //
% //
% //  ******* Non Linear Version *********
% //
% // 
% //********************************************************************************************


clear all; close all; clc

dynare model_NK_forecast
close all;

nvars  = char('y', 'i','c', 'w', 'l', 'k', 'z', 'R', 'pip');

% --------------------------
% Plot IRFs - Ramsey Policy
% --------------------------

    warning off

    vnamesd = {'Output ($\hat{y}_{t}$)','Investment ($\hat{i}_{t}$)','Consumption ($\hat{c}_{t}$)',...
                    'wage ($\hat{w}_{t}$)','labor ($\hat{l}_{t}$)',...  
                    'Capital ($\hat{k}_{t}$)','Rental rate of capital ($\hat{z}_{t}$)',...
                    'Nominal Interest rate ($\hat{R}_{t}$)','Inflation ($\hat{\pi_{t}}$)'};

    nshock = char('_eps_techno');  
    nnames = char('Techno Shock');

    for ss = 1 : 1;
        nirfd1 = [];
        nshock1 = cellstr(nshock(ss,:));
        nshocks = char(nshock1);

        for i = 1 : size(nvars,1)
            nvars1 = cellstr(nvars(i,:));
            nvarss = char(nvars1);
            nvarss = ['oo_.forecast.Mean.',nvarss];
            nirfd = eval(nvarss);
%             nirfd = eval([nvarss,nshocks]);
            nirfd1 = [nirfd1 nirfd];
        end

        hor = 30;
        figure('name',nnames(ss,:))
        for vv = 1 : length(nvars)
             subplot(3,3,vv)
             zz = nirfd1(1:hor,vv);
             zz0 = plot(0:1:hor-1,zz);
             set(zz0(1),'LineWidth',1,'color',[0.7 0.2 0.4])
             set(gca,'Xlim',[0 hor],'XlimMode','manual','fontsize',5)
             t1 = title(vnamesd{vv});
             set(t1,'fontsize',8,'interpreter','latex')
             set(gcf,'Units','inches','PaperUnits','inches')
             set(gcf,'PaperPosition',[.25 .25 7.77 11.19]);
            fn = sprintf('plotirf%d',i);
            set(get(gca,'XLabel'),'String','Periods after shock','fontname','times','fontsize',5)
            set(get(gca,'YLabel'),'String','Percent deviation','fontname','times','fontsize',5)
        end
        
          

    end
    
