function [resid] = f_gst(X, paraset)

kappa = X(1);

%install parameters-----------------------------------------------------
h = paraset(1);
beta = paraset(2);
mu_zss  = paraset(3);
piss  = paraset(4);
mu_k  = paraset(5);
deltass  = paraset(6);
gyss  = paraset(7);
nss  = paraset(8);
sigma_m  = paraset(9);
sigma  = paraset(10);
alpha = paraset(11);
xi_w = paraset(12);
gamma_w  = paraset(13);
bbar  = paraset(14);
rho  = paraset(15);
phi_r  = paraset(16);
phi_pi  = paraset(17);
phi_y  = paraset(18);
xi_p  = paraset(19);
lambda_pss  = paraset(20);
zeta = paraset(21);
etass = paraset(22);
gamma_p = paraset(23);
rhoss = paraset(24);
%-----------------------------------------------------------------------
%--------------------------------------------------------------------------

%STEADY STATE VALUES OF ENDOGENOUS VARIABLES-------------------------------
pi_oss=piss;
sdfss=beta/mu_zss;
r_nss=piss*mu_zss/beta;
r_kss=deltass/mu_k;
u_kss=1;
q_kss=1;
uss=1-nss;
xss=1-rhoss;
sss=nss/(1-nss)*(1-rhoss);
mss=nss*(1-rhoss);
vss=((1-rhoss)/sigma_m*nss/(1-nss)^sigma)^(1/(1-sigma));
qss=nss*(1-rhoss)/vss;
p_wss=1/(1+lambda_pss);
yss=(alpha*beta/(mu_zss-beta*(1-deltass))/(1+lambda_pss))^(alpha/(1-alpha))*nss;
%ass=(1-alpha)*yss/nss;   
ass=(1-alpha)*(alpha*beta/(mu_zss-beta*(1-deltass))/(1+lambda_pss))^(alpha/(1-alpha));
%kss=alpha*beta*mu_zss/(mu_zss-beta*(1-deltass))*yss/(1+lambda_pss);
kss=mu_zss*(alpha*beta/(mu_zss-beta*(1-deltass))/(1+lambda_pss))^(1/(1-alpha))*nss;
iss=(mu_zss-1+deltass)/mu_zss*kss;
css=(1-gyss)*yss-iss;
delta_primess=deltass/mu_k;
k_pss=1/(1+lambda_pss)/(1-beta*xi_p)...
    *(alpha*beta/(mu_zss-beta*(1-deltass))/(1+lambda_pss))^(alpha/(1-alpha))...
      *nss;
f_pss=(1+lambda_pss)*k_pss;
Sss=0; 
S_primess=0;
lambda_css = (mu_zss-beta)/(mu_zss-h)/css; 
Jss=kappa*(1-rhoss);
Hss=etass/(1-etass)*(1-beta*xi_w)/(1-beta*rhoss*xi_w)*kappa*(1-rhoss);
%wss=(1-beta*(rhoss-sss))*Hss+bbar*kss;
wss=(1-beta*(rhoss-nss)/(1-nss))*etass/(1-etass)*(1-beta*xi_w)/(1-beta*rhoss*xi_w)*kappa*(1-rhoss)...
    +bbar*mu_zss*(alpha*beta/(mu_zss-beta*(1-deltass))/(1+lambda_pss))^(1/(1-alpha))*nss;
w_oss=wss;

%--------------------------------------------------------------------------
resid = zeros(1,1);
%resid(1) = -Jss + p_wss*ass -wss  -sdfss*kappa*mu_zss*xss^2 +sdfss*(rho+xss)*Jss*mu_zss;
resid(1)=-Jss+p_wss*ass-w_oss+sdfss*mu_zss*(xi_w*(rhoss*Jss+Jss^2/2/kappa)+(1-xi_w)*(rhoss*Jss+Jss^2/2/kappa));