%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 = 1;

%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)

YSS1 = x(1);
ZSS1 = x(2);
RSS1 = x(3);
PAISTAR1 = PAISS;
GSS1 = GSS;
BSS1 = BSS;
SSS1 = SSS;
XSS1 = XSS;
LSS1 = SSS1*YSS1^(1/SIGMA);
CSS1 = YSS1 - GSS1;
ISS1 = (1+RSS1) * PAISTAR1 -1;
MSS1 = CSS1 * ZSS1;
MUSS1 = PAISTAR1;
TSS1 = GSS1 + BSS1*RSS1/(1+RSS1) + MSS1*(PAISTAR1-1)/PAISTAR1;
WSS1 = (ZSS1^(-DELTHA)*ETA*LSS1^(EPSI-1))/(1-DELTHA);
VSS1 = MSS1/PAISTAR1 + BSS1;
PSISS1 = WSS1*YSS1^(1/SIGMA)/SIGMA / (1-ALPHA*PAISTAR1^(THETA/SIGMA)/(1+RSS1));
PHISS1 = YSS1 /(1-ALPHA*PAISTAR1^(THETA-1)/(1+RSS1));


savefile = 'ss_values.mat';
save(savefile);


