clear

setpathdynare6_3;

%% Run model

dynare rbcb_monetary_prudential noclearall  

order = 2;
nperiods = 20;

burn_in = 5000;
shock_label = char('erra'); % innovation list
shock_size = [0.01];        % shock sizes matching innovaution lists
nreps = 1000;
std_vec = [0.01 0 0 0 0 0]';  % standard deviations of shocks in the model -- order follows M_.exo_names

f1 = makeirfsecondorder_stochastic(M_,oo_,burn_in,shock_label,shock_size,nperiods,nreps,std_vec);
%%%%%%%%%%%%% END do not change %%%%%%%%%%%


dynare rbcb_monetary_prudential noclearall  

shock_names = char('erra'); % innovation list
shock_size = [0.01];        % shock sizes matching innovation lists
prefix = 'f2';              % prefix for recording IRFs 

%%%%%%%%%%%%% BEGGING do not change %%%%%%%%%%%
shocks = zeros(M_.exo_nbr,1);
nshocks = size(shock_names,1);
for indxi=1:nshocks
    shock_pos = strmatch(shock_names(indxi,:),M_.exo_names,'exact');
    shocks(shock_pos)=shock_size(indxi);
end

eval([prefix,'=makeirfsecondorder(M_,oo_,nperiods,shocks,order);']);

%%%%%%%%%%%%% END do not change %%%%%%%%%%%


titlelist = char('Technology', 'Output',...
                 'Investment', 'Consumption ',...
                 'Return on Firm Equity (ar) ','Spread -- Expected Return on Firm Equity minus Deposit Rate (ar)',...
                 'Deposit Rate (ar)','Bank Equity');
figlabel = '';

legendlist = char('New Keynesian Model with Banks', 'New Keynesian Model with Banks and Macroprudential Rule');

pc = 'Percent Dev. from SS';
ppt = 'PPt. Dev. from SS';

ylabels = char(pc, pc,...
               pc, pc,...
               ppt, ppt,...
               ppt, pc);

line1 = 100*[f1.a_irf f1.y_irf/f1.y_ss ...
              f1.in_irf/f1.in_ss f1.c_irf/f1.c_ss ...
              f1.rs_irf*4 f1.spread_irf*4 ...
              f1.r_irf*4 nan*f1.a_irf];
          

line2 = 100*[f2.a_irf f2.y_irf/f2.y_ss ...
              f2.in_irf/f2.in_ss f2.c_irf/f2.c_ss ...
              f2.rs_irf*4 f2.spread_irf*4 ...
              f2.r_irf*4 f2.n_irf/f2.n_ss];          

          
makechart(titlelist,legendlist,figlabel,ylabels,line1,line2)


titlelist= char('Price of Capital','Loan Rate (ar)', ...
                'Loans','Hours worked',...
                'Wages','Loans to Equity');
figlabel = '';
ylabels = char(pc, ppt,...
               pc,pc,...
               pc, ppt);
line1 = 100*[f1.q_irf, f1.rs_irf*4 ...
              nan*f1.q_irf f1.l_irf/f1.l_ss ...
              f1.w_irf/f1.w_ss nan*f1.q_irf];
          


                    
line2 = 100*[f2.q_irf, f2.rs_irf*4 ...
              f2.s_irf/f2.s_ss f2.l_irf/f2.l_ss ...
              f2.w_irf/f2.w_ss f2.l2n_irf];

          
makechart(titlelist,legendlist,figlabel,ylabels,line1, line2)

