clear all;
clc;


%parameters
us=0.1525;
qs=0.7;
rho_zero=0.1;
mu=0.5;
eta=0.5;
b_bar=0.73;
beta=0.99;
pis=1;
sigma=2;
epsilon_p=11;
kappa_p=20;
rhor=0.8;
phipi=2;
phiy=0.3;
rhoer=0;
rhoa=0.8976;
sigma_a=0.00934;
sigma_r=0;
gamma=1;
phic=0.00001;
%steady state
guess =1.5;
As=1;
b=b_bar*As;
%eq 6
ns=(1-us)/(1-rho_zero);
%eq7
u_ms=1-ns;
%eq5
vs=rho_zero*ns/qs;
%eq8
thetas=vs/us;
%eq 2
ms=qs*vs;
%eq 10
m_zero=qs*(thetas^(mu));
%eq 9
fs=m_zero*(thetas^(1-mu));
%eq 15
phis=(epsilon_p-1)/epsilon_p;
%eq 4
Rs=1/beta;

%eq 20
sigs=((1-gamma+gamma*Rs)/(phic*phis*As*(ns^(1-phic))))^(1/(phic-1));

%eq 11 et 16
kappa_v=qs*((eta-1)*As*(sigs^(phic))*(ns^(-phic))*(1-phic)*phis+(1-gamma+gamma*Rs)*(1-eta)*b)/(eta*beta*(1-rho_zero)*(1-fs)-eta*(1-rho_zero)*beta+(1-rho_zero)*beta-1);

%eq 12
Js=kappa_v/qs;

%eq 16
ws=((kappa_v/qs)*((1-rho_zero)*beta-1)+phis*(1-phic)*As*(sigs^(phic))*(ns^(-phic)))/(1-gamma+gamma*Rs);
%eq 13
Xs=As*(ns^(1-phic))*sigs^(phic);
%eq 21
ys=Xs-sigs;
%eq 1
cs=ys;
%eq 3
lams=cs^(-sigma);
LCs=(1-gamma+gamma*Rs)*ws;


save parameter_mainlininput4 sigs Xs phic Js LCs thetas eta rho_zero mu m_zero rhoa b kappa_p kappa_v epsilon_p beta gamma sigma us ns vs ms u_ms fs qs ys  As  phis pis lams Rs ws cs sigma_a sigma_r rhor rhoer phipi phiy
 dynare model_lininput4
IRF1 =oo_.irfs;
STD1=oo_.var;
AUT1=oo_.autocorr;
save IRF1 
save STD1
save AUT1