%neil_taylor_steadystate.m


ALPHA = 0.75;
SIGMA = 1;
THETA = 10;
BETTA = 0.96^0.25;
Q=1-1/70;
%Q = 0.9967;
DELTHA = 0.02;
EPSI = 2;

% CALIBRATION OF ETA SUCH THAT Y IS NORMALIZED TO 1 IN A ZERO INFLATION
% STEADY STATE WITH B=G=0

CHI = DELTHA*(BETTA^-1-Q)*(Q^-1-1) / (1-SIGMA*(THETA-1)*(1-DELTHA)/EPSI/THETA);
X0RSS = 0.5 * ((BETTA^-1-1+CHI) + ((BETTA^-1-1+CHI)^2+4*CHI)^0.5);
X0ZSS = DELTHA / (1-DELTHA) * (1 + X0RSS)/ X0RSS;
ETA = SIGMA * (THETA-1)* (1- DELTHA) / THETA * X0ZSS^DELTHA;

%EXOGENOUS VARIABLES

PAISS = 1;
GSS = 0;
BSS = 0;

%ENDOGENOUS VARIABLES

XSS=((1-ALPHA*PAISS^(THETA-1))/(1-ALPHA))^(1/(1-THETA));
SSS=(1-ALPHA)*XSS^(-THETA/SIGMA)/(1-ALPHA*PAISS^(THETA/SIGMA));

x0 = [ 1 X0ZSS X0RSS];
%x=[Y, Z, r]
toll=1e-20;
OPTIONS=optimset('MaxFunEvals',100000,'MaxIter',100000,'TolFun',toll,'TolFun',toll);
[x, fval, exitflag] = fminsearch(@(x) nonlinear_guido(x, BETTA, ALPHA, THETA, SIGMA, DELTHA, PAISS, BSS, GSS, EPSI, SSS, Q, ETA), x0,OPTIONS)

YSS0 = x(1);
ZSS0 = x(2);
RSS0 = x(3);
PAISTAR0 = PAISS;
GSS0 = GSS;
BSS0 = BSS;
SSS0 = SSS;
XSS0 = XSS;
LSS0 = SSS0*YSS0^(1/SIGMA);
CSS0 = YSS0 - GSS0;
ISS0 = (1+RSS0) * PAISTAR0 -1;
MSS0 = CSS0 * ZSS0;
MUSS0 = PAISTAR0;
TSS0 = GSS0 + BSS0*RSS0/(1+RSS0) + MSS0*(PAISTAR0-1)/PAISTAR0;
WSS0 = (ZSS0^(-DELTHA)*ETA*LSS0^(EPSI-1))/(1-DELTHA);
VSS0 = MSS0/PAISTAR0 + BSS0;
PSISS0 = WSS0*YSS0^(1/SIGMA)/SIGMA / (1-ALPHA*PAISTAR0^(THETA/SIGMA)/(1+RSS0));
PHISS0 = YSS0 /(1-ALPHA*PAISTAR0^(THETA-1)/(1+RSS0));





