
% Simulate NKPC and responses to cost-push shocks in full model
% under monetary shocks


dynare NL_Rotem_sim

%% Baseline simulations

% Simualte the model for 10,000 periods with monetary shocks only to get a
% Phillips curve schedule. Scale the shock std. such that we get -15% to 15%
% variation in the output gap

nshocks      = 6;
nperiods     = 1000;
covmat       = sqrt(M_.Sigma_e); % 冲击标准差
initvals     = oo_.steady_state;
shock_name   = 'eps_M'; % Shock
shock_i      = strmatch(shock_name, M_.exo_names, 'exact'); % impulse shock position
shocks_scale = 3;
options_.debug=1;
options_lin = options_;

options_lin.linear_approximation = 1;

% create shock matrices for simulations
shock_mat  = zeros(nperiods,nshocks); % matrix for simulation with all shocks active
shock_draw = shocks_scale*covmat(shock_i,shock_i).*randn(nperiods,1);
shock_mat(:,shock_i) = shock_draw;

tic
sim_mat     = my_extended_path(initvals, nperiods, shock_mat, options_, M_, oo_);
%sim_mat_lin = my_extended_path(initvals, nperiods, shock_mat, options_lin, M_, oo_);
simtime = toc;

%% plot baseline simulations

yi     = strmatch('y',M_.endo_names,'exact');
cpi    = strmatch('PI_C',M_.endo_names,'exact');
ppi    = strmatch('PI_I',M_.endo_names,'exact');


figure
a = plot(sim_mat(yi,:),4*sim_mat(cpi,:),'bo','linewidth',1);hold on
b = plot(sim_mat(yi,:),4*sim_mat(ppi,:),'r+','linewidth',1);hold on
legend([a,b],'CPI','PPI')
legend('boxoff')
hold on 
set(gca,'Fontsize',18,'Color','none')
grid
ylabel('通胀')
xlabel('产出缺口')
title('投资冲击')
    

