clear all
close all
clc

% -----------------------------------------------------------------------
% 1) RUN first "benchmark model''
% -----------------------------------------------------------------------
dynare models1

% -----------------------------------------------------------------------
% 2) Record parameter value and steady state value
%       they will be used to initalize the next model but when the 
%       tax will change. I define new param like "param_"
% -----------------------------------------------------------------------

% PARAMETERS 

betas_=betas;betau_=betau;eta_=eta;alpha_=alpha;r_=r;
ds_=ds;du_=du;Ns_=Ns;Nu_=Nu;yfu_=yfu;yfs_=yfs;tauw_=tauw;
tauf_=tauf;Ai_=Ai;gammas_=gammas;gammau_=gammau;z_=z;
rho_=rho;xs_=xs;xu_=xu;

% STEADY STATE VARIABLES 

us_bar_=us_bar;  uu_bar_=uu_bar;
uLi_bar_=uLi_bar;thetas_sq_bar_=thetas_sq_bar;
thetau_uq_bar_=thetau_uq_bar;sq_bar_=sq_bar;
uq_bar_=uq_bar;thetas_bar_=thetas_bar;
thetau_bar_=thetau_bar;Lfs_bar_=Lfs_bar;
Lfu_bar_=Lfu_bar;Ms_bar_=Ms_bar;
Mu_bar_=Mu_bar;vs_bar_=vs_bar;
vu_bar_=vu_bar;sw_bar_=sw_bar;
uw_bar_=uw_bar;wi_bar_=wi_bar;
yi_bar_=yi_bar;

% return
% -----------------------------------------------------------------------
% 3) Simulate the model for different value of the taxes
% Here I use the parameters and the steady state saved above
% Note that here I change the tax tauw 
% -----------------------------------------------------------------------

% a) Here are the vector of taxes (I just consider the first)
tauw_vec =0.15;	%benchmark is tauw =0.15;
%tauw_vec =0.20;
%tauw_vec =025;


% b) I initialize the steady state for (unemployment) which is now
%    a vector whose dimension will be the number of different value
%    for the tax

us_simul=zeros(length(tauw_vec),1);
uu_simul=zeros(length(tauw_vec),1);

Lfs_simul=zeros(length(tauw_vec),1);
Lfu_simul=zeros(length(tauw_vec),1);

sw_simul=zeros(length(tauw_vec),1);
uw_simul=zeros(length(tauw_vec),1);

uLi_simul=zeros(length(tauw_vec),1);



disp('simulation')

for i=1:length(tauw_vec)
   
    
    % a) I define the new value of the tax
    tauw_=tauw_vec(i);
    
    %z_ =z_vec(ii);
    
    % b) I run the model which does not recalculate the parameter 
    %    to pin down the steady state;
    
    dynare models2
    
    % c) Then I record the variables (here just unemployment)
    us_simul(i)=oo_.steady_state(3);
    uu_simul(i)=oo_.steady_state(4);
    
    sw_simul(i)=oo_.steady_state(9);
    uw_simul(i)=oo_.steady_state(10);
    
    uLi_simul(i)=oo_.steady_state(15);
    
    Lfs_simul(i)=oo_.steady_state(17);
    Lfu_simul(i)=oo_.steady_state(18);
    
  

end

subplot(331), plot(us_simul(i)), grid on, title('skilled unemployement');
subplot(331), plot(uu_simul(i)), grid on, title('unskilled unemployement');
subplot(333), plot(sw_simul(i)), grid on, title('Formal skilled wage');
subplot(334), plot(uw_simul(i)), grid on, title('Formal unkilled wage');
subplot(335), plot(wi_simul(i)), grid on, title('Informal wage');
subplot(336), plot(uLi_simul(i)), grid on, title('Informal Employment');
subplot(337), plot(Lfs_simul(i)), grid on, title('Skilled Employment');
subplot(338), plot(Lfu_simul(i)), grid on, title('Unskilled Employment');





% -----------------------------------------------------------------------
% NOTE: the order of steady state variable in oo_.steady_state is
% given by the order when the variable are declared in the .mod file
% 1 Ms 
% 2 Mu 
% 3 us 
% 4 uu
% 5 vs 
% 6 vu 
% 7 sq 
% 8 uq 
% 9 sw  
% 10 uw  
% 11 wi 
% 12 thetas 
% 13 thetau 
% 14 yi 
% 15 uLi 
% 16 a 
% 17 Lfs 
% 18 Lfu
