%fix x = 0.25 to calibrate

alpha=0.4;
beta = 0.98;
delta = 0.05;           % capital depreciation rate
open=0.85;
gamma=2;
eta=0.5;
phipi=1.5;                
phiy=0.0125; 
kappaI = 5;
rhoa=0.9;
rhor=0.8;
slope= 2/3;
pi_ss=1;



sigma=0.94;
leta = 0.0045 ;
Rstar=1.01; 


R=1/beta;
x = 0.25;
lev = 4;
Rk = (1-sigma/beta-sigma*(1/beta-Rstar)*x*lev-lev*leta)/(sigma*lev)+1/beta;
omega = (1-sigma)/(1-sigma-sigma*lev*((beta*Rk-1)+x*(1-beta*Rstar)));
mu=omega;
muk = beta*(Rk-1/beta)*omega;
mustar = beta*(1/beta-Rstar)*omega;
aux1 =muk/mustar;
kappaX = 2/((x+aux1)^2-aux1^2);                  %kappaX calibration
theta = (mu/lev+muk+x*mustar)/(1+kappaX/2*x^2);  %theta calibration


eps = 9;
slope= 2/3;
kappaP = (eps-1)*slope/((1-slope)*(1-beta*slope));

chi = 2;
phi = 1/3;

q = 1;
pi=1;
pH = 1;
s=1;
A=1;

mc = (eps-1)/eps;
z = Rk-1+delta;
w = (A*mc/z^alpha*alpha^(alpha)*(1-alpha)^(1-alpha))^(1/(1-alpha));
L = (w/chi)^(1/phi);
K = alpha/(1-alpha)*(w*L)/z;
Y=A*K^(alpha)*L^(1-alpha);
i = delta*K;
n =K/lev;
Bstar = x*lev*n;
B = (lev-1-x*lev)*n;
C = Y-i-Bstar*(Rstar-1);
%c_star = Y-open*(C+i);
c_star = Y-open*C-i;
lambda = (C-chi/(1+phi)*L^(1+phi))^(-gamma);    

Y_ss = Y;



save par beta alpha chi gamma phi delta open sigma kappaX theta leta...
    kappaI eta rhoa rhor eps kappaP pi_ss Y_ss ...
    phipi phiy c_star Rstar;

save ss.mat C L Y K i n B Bstar lambda omega muk mu mustar x lev R pH q Rstar s Rk A ...
 mc pi z w ;