function [ys,check] = SOE_steadystate(ys,exe)
global M_ lgy_ options_

if isfield(M_,'param_nbr') == 1
NumberOfParameters = M_.param_nbr;
for i = 1:NumberOfParameters
  paramname = deblank(M_.param_names(i,:));
  eval([ paramname ' = M_.params(' int2str(i) ');']);
end
check = 0;
end

beta = 0.9889;      % annual (gross) deposit rate = 4.45%
eta = 1;            % elasticity substitution consumption/housing =1 (cobb douglas)
delta = 0.005;      % annual housing depreciation 2% (like Aoki et al.)
mud = 6;            % elasticity of substitution between domestic varieties 
                    % implies markup in domestic sector = 1.2
muf = 6;            % elasticity of substitution between varieties of imported good
                    % markup in import sector = 1.2
alpha = 0.25;       % share of domestic good in consumption
phi = 1;            % elasticity of substitution domestic/foreign goods
bigomega = 0.35;    % share capital in production Elekdag and Tchakarov (2007)
                    % Gertler, Gilchrist & Natalucci set 0.5
alphastar = 0.1;    % percentage domestic goods in foreign consumption (pins down foreign GDP)                    
xi_h = 0.105;      % scaling housing services

S = 1;              % nominal exchange rate normalized to 1
Z = 1;              % Total factor productivity normalized to 1
ph = 1;             % relative price housing services
pd = 1;             % relative price domestic good
Pd = 1;             % price domestically produced good
pf = 1;             % relative price imported good
Pf = 1;             % price importd good
Pc = 1;             % price composite consumption good
Pdstar = 1;         % export price domestic good
pic = 1;            % CPI inflation
pid = 1;            % inflation dimestic good
pif = 1;            % inflation imported good

bigphi = 1;         % steady state value risk premium

R = 1/beta;         % domestic risk free rate
Rstar = 1/beta;     % foreign risk-free rate
q = 1;              % price housing stock
mcd = (mud-1)/mud;  % marginal cost domestic producers
Pf_star = (muf-1)/muf;  % foreign price import good





Rh = R;                         % return to housing investment

s = Rh - (1-delta);                 % fraction housing services

N = 0.33;                           % labor 1/3 total time
K = 3;                              % capital (exogenous)

Yd = (K^bigomega)*(N^(1-bigomega)); % domestic production

G = 0.3*Yd;                         %gov expenditure 30% of gdp

H = (Yd-G)/( (1/xi_h)*s + delta);

h = s*H;                            % housing services

C = (h/xi_h)*ph;                                            % aggregate consumption

I = delta*H;                                                % investment in housing sector

Yf = (1-alpha)*(Pf/Pc)^(-phi)*(C + I);                      % imports

Cd = alpha*(pd)^(-phi)*C;                                   % consumption domestic good

Cf = (1-alpha)*(pf)^(-phi)*C;                               % consumption foreign good

w = mcd*pd*(1-bigomega)*(Yd/N);                             % real wage

epsilon_n = w*(1-N)/C;                                             % adjust xi to match labor supply equation

Yx = Yf;                                                    % exports equal imports in SS

af = 1;

Ystar = alphastar*Yx;

Id = alpha*(pd)^(-phi)*I; 

If = (1-alpha)*(pf)^(-phi)*I;
                                                          
% save steady state values of variables


S_ss = S;
Z_ss = Z;              
ph_ss = ph;
pd_ss = pd;             
Pd_ss = Pd;             
pf_ss = pf;             
Pf_ss = Pf;            
Pc_ss = Pc;             
pdstar_ss = Pdstar;         
pi_c_ss = pic;           
pi_d_ss = pid;            
pi_f_ss = pif;            
bigphi_ss = bigphi;         
R_ss = R;
Rstar_ss = Rstar; 
q_ss = q;              
mcd_ss = mcd; 
pfstar_ss = Pf_star;  
Rh_ss = Rh;                         
s_ss = s;                 
n_ss = N;                           
K_ss = K;                              
y_ss = Yd;
G_ss = G;                        
H_ss = H;
h_ss = h;
c_ss = C;
I_ss = I;
yf_ss = Yf;
cd_ss = Cd;
cf_ss = Cf; 
w_ss = w; 
yx_ss = Yx;
af_ss = af;
ystar_ss = Ystar;
Id_ss = Id;
If_ss = If;
epsilon_n = epsilon_n;

%%
for iter = 1:length(M_.params)
  eval([ 'M_.params(' num2str(iter) ') = ' M_.param_names(iter,:) ';' ])
end

if isfield(M_,'param_nbr') == 1

if isfield(M_,'orig_endo_nbr') == 1
NumberOfEndogenousVariables = M_.orig_endo_nbr;
else
NumberOfEndogenousVariables = M_.endo_nbr;
end
ys = zeros(NumberOfEndogenousVariables,1);
if options_.linear
    
else
for i = 1:NumberOfEndogenousVariables
  varname = deblank(M_.endo_names(i,:));
  eval(['ys(' int2str(i) ') = ' varname ';']);
end
end

else
ys=zeros(length(lgy_),1);
for i = 1:length(lgy_)
    ys(i) = eval(lgy_(i,:));
end
check = 0;
end
