clear all;
clc;

pibar =1.0375^(0.25);
%pibar=1;
% fixed parameters
hc=0.0001;
beta = 0.99;




xi=0.5;
eta=1;

epsilon=0.5;
deltap=2/3;
gammap = 0;

gamma=10;



%paramètre de Taylor
rhor=0.8;
phipi=1.5;
phiy=0.125;

% shocks

rhoa=0.95;

rhoer=0;

% guess of shocks
sur = 0.0033;

sua = 0.0049;


ppi=1; % if =0 no KC if =1 with capital
phi=0.00001; %%=0 no input inter if not with 0.52*markup=0.572 or markup gamma/(gamma-1)
%steady state

%eq 21

ps=((1-deltap*pibar^((gammap-1)*(1-gamma)))/(1-deltap))^(1/(1-gamma));

%eq 19

ss=((1-deltap)*ps^(-gamma))/(1-deltap*pibar^((gammap-1)*(-gamma)));
%eq 3
Rs= (pibar/beta)-1;
% eq 23 24 22 
%mcs = ((gamma-1)/gamma)*((1-deltap*pibar^((gammap-1)*(1-gamma)))/(1-deltap))^(1/(1-gamma))*(1-deltap*beta*pibar^((gammap-1)*(1-gamma)))^(-1)*(1-deltap*beta*pibar^(-gamma*(gammap-1)));
mcs=1;
%31
psi_sigs=1-ppi+ppi*(1+Rs);
%32
psi_ns=1-ppi+ppi*(1+Rs);
%33

%eq 4:lar=lb
%eq 5 avec z=1



guess =1.5;
b=0.4; %shimer 2005
As=1;
lamb=0.1;%% consistent with 0.034 monthly separation rate by shimer 2005(range between 0.07 
        %%merz (1995) to 0.15 Andolfatto (1996)
qs=0.7; %clerc pierrick ; den haan et al 2000
us=0.11; %unemployment rate target of 11 percent in toledo et silva 2010 p.27 and kraus eand lubik =0.12 p.716 2007

%(correspond a 0.34 monthly in shimer see sveen and Francesco Furlanettoy 2009 )
 
 
 ns=1-us; %eq 9
 pts=lamb*ns/(1-ns); %selon eq 15
 
 
 ms=pts*us; %eq 17
 vs=ms/qs; %eq 18
 
 thetas=vs/us; % eq 10
 
zeta=pts/(thetas^epsilon); %eq 16


hs=1; %(comme dans alves)

%6 and 30
sigs=(psi_sigs/(phi*mcs*As*(ns*hs)^(1-phi)))^(1/(phi-1));
%eq14
mpls=(1-phi)*As*((sigs)^(phi))*(ns*hs)^(-phi); %%RC

Xs=ss*As*(sigs^(phi))*(ns*hs)^(1-phi);


ys=Xs-sigs;
%25

cs=(mpls*mcs*(1-beta*hc)/((1-hc)*(hs^eta)))*(((1-xi)*psi_ns+xi+(1-psi_ns)*(1-xi))/((1-xi)*psi_ns+xi+(psi_ns-1)*xi));




%khi=0.1; %% à vérifier
khi=0.01*ys*((1-beta*hc)/(cs*(1-hc)))/vs;
%eq 7
ws=xi*(b/((1-beta*hc)/(cs*(1-hc)))+(hs^(1+eta))/((1+eta)*((1-beta*hc)/(cs*(1-hc)))))+((1-xi)/psi_ns)*(mcs*mpls*hs+khi*thetas/((1-beta*hc)/(cs*(1-hc))));

%eq 1
lars=((1-beta*hc)/(cs*(1-hc)));


x1s=(lars*mcs*Xs)/(1-(deltap*beta*pibar^((-gamma)*(gammap-1)))); %%RC
%24
x2s=(lars*Xs)/(1-(deltap*beta*pibar^((1-gamma)*(gammap-1)))); %%RC
Hs=ns*hs;

save parameter_main1  Hs hc rhoer ppi beta sigs  phi Xs psi_ns psi_sigs  xi khi eta  b lamb zeta epsilon deltap gammap rhoa rhor phipi phiy gamma pibar sua sur  ps ss Rs mcs As pts ns us ms vs thetas qs hs   mpls ys cs lars  x1s x2s ws  Rs

 dynare Clara_ramsey_nash