Fix trust-region termination criterion
The following mod-file says a steady state has been computed, but the residuals show that is not the case. I have no clue why.
//-------------------------//
// 1. Endogenous Variables //
//-------------------------//
var
Y,YFstar,
PH,P,PHstar,Pstar,PF,PFstar,
Pi,Pistar,PiH,PiF,PiHstar,PiFstar,
C,Cstar,
i,istar,
DF,DFstar,
S,Q,
W,N,Wstar,Nstar,
CC,
F, K, Fstar, Kstar, PD,PDstar,
A, Astar,RP,U;
//---------------------//
// 2. Exogenous shocks //
//---------------------//
varexo
e, // [E.1] Home Productivity Shock
estar, // [E.2] Foreign Productivity Shock
erp; // [E.3] Risk Premium Shock
//--------------------//
// 3. Parameter names //
//--------------------//
parameters
BETA,SIGMA,PHI,ETA,THETA,EPSILON,CHI,ALPHA,ALPHAstar,TAUL,KAPPA,PHIPIH,PHIY,DBar;
//---------------------//
// 4. Parameter values //
//---------------------//
BETA = .99; // [P.1] Intertemporal Discount Factor
SIGMA = 1; // [P.2] Coefficient of Risk Aversion
PHI = 3; // [P.3] Inverse of Labor Supply elasticity
ETA = 3; // [P.4] Elasticity of Substitution btw Home and Foreign Goods For Gali and Monacelli it is 1 and foreign economy does not effect
THETA = 1-(0.75^4); // [P.5] Price stickiness parameter this value implies average period of one year btw price adjustments
EPSILON = 6; // [P.6] Elasticity of substitution among goods
CHI = 0.000742; // [P.7] Following Justiano and Preston (2010)
ALPHA = 0.4; // [P.8] Degree of Openness(Following Gali and Monacelli (2005))
ALPHAstar = 0.000001; // [P.9] Degree of Openness for Foreign Economy I assume it is a closed economy
TAUL = -1/EPSILON; //[P.10] Steady State Labor Tax Gali and Monacelli (2005)
PHIPIH = 4; // [P.11] Weight of Domestic Inflation in Policy Rule
PHIY = 0.2; // [P.12] Weight of Output in Policy Rule
KAPPA = 0.66; //Autoregressive Coefficient CHECK!!!
DBar = 1.0105;
//---------------------//
// 5A. Model Equations //
//---------------------//
model;
//---------DEMAND BLOCK-----//
Y=(1-ALPHA)*(PH/P)*C+ALPHAstar*(PHstar/Pstar)*Cstar;
//Y = (1-ALPHA)*((S*Pstar*PH)/(P*PF))^(-ETA)*C+ALPHA*(PF/PH)*Cstar; // [1] Home demand equation // [2] Demand for home goods by home consumers
DF=-DFstar;//YFstar=Cstar; // [4] Demand for foreign goods by foreign consumers
YFstar=Cstar;
//C=BTHETA*Cstar*Q^(1/SIGMA);
//(BTHETA(+1)/BTHETA)^SIGMA=((1+i)*S)/((1+istar+((CHI*(exp(DF-DBar)-1)+RP)))*S(+1)*(1+CC));
//NFA=-(Cstar^SIGMA)*((PH*Y/PF)-C/Q)+BETA*NFA(+1);
//---------Price Indexes-----//
P^(1-ETA)=((1-ALPHA)*(PH^(1-ETA))+ALPHA*(PF^(1-ETA))); //[5] Home Price Index
Pstar^(1-ETA)=((ALPHAstar)*(PHstar^(1-ETA))+(1-ALPHAstar)*(PFstar^(1-ETA))); //[6] Foreign Price Index
//---------Euler Equations-----//
(BETA)*(1+i)=((C(+1)/C)^(SIGMA))*(P(+1)/P); //[7] Home Euler Equation (Domestic Bonds)
(BETA)*((1+istar)*((CHI*(exp(DF-DBar)-1)+RP)))*(1+CC)=((C(+1)/C)^(SIGMA))*(P(+1)*S/(P*S(+1))); //[8] Home Euler Equation (Foreign Bonds)
(BETA)*(1+istar)=((Cstar(+1)/Cstar)^(SIGMA))*Pistar; //[9] Foreign Euler Equation
//---------Budget Constraints-----//
P*C+((S*DF)/((1+istar)*(CHI*(exp(DF-DBar)-1)+RP)))=W*N+(1+CC(-1))*S*DF(-1); //[10] Home Budget Constraint
Pstar*Cstar+(DFstar/(1+istar))=Wstar*Nstar+DFstar(-1); //[11] Foreign Budget Constraint
//---------Labor Market Conditions-----//
W/P=(C^(SIGMA))*(N^(PHI)); //[12] Home Market Condition
Wstar/Pstar=(Cstar^(SIGMA))*(Nstar^(PHI)); //[13] Foreign Market Condition
//---------Some Identities, Terms of Trade-----//
Pi=P(+1)/P; //[14] Home inflation Index
Pistar=Pstar(+1)/Pstar; //[15] Foreign inflation Index
Q=S*Pstar/P; //[16] Real Exchange Rate
PiH=PH(+1)/PH; //[17] Domestic Good Price Inflation
PH=S*PHstar; //[18] Law of One Price
PiHstar=PHstar(+1)/PHstar; //[19] Domestic Goods Inflation in Foreign Country
PiF=PF(+1)/PF; // [20] Foreign Good Price Inflation
PF=S*PFstar; //[21] Law of One Price
PiFstar=PFstar(+1)/PFstar; //[22] Foreign Good Inflation in Foreign Country
//Pi=PiH*((PF*Q(-1)*PH(-1))/PH*Q*PF(-1));
//-------------------Price Setting-----------------//
(1-(THETA*(PiH(-1)^(EPSILON-1))))/((1-THETA)*(PH^(EPSILON-1)))= (F/K)^(EPSILON-1); //[23] FOC for Home Country optimal price setting
(1-(THETA*(PiFstar(-1)^(EPSILON-1))))/((1-THETA)*(PF^(EPSILON-1)))= (Fstar/Kstar)^(EPSILON-1); //[24] FOC for Foreign Country optimal price setting
K=(EPSILON/(EPSILON-1))*((1+TAUL)/A)*(W/P)+THETA*BETA*K(+1); //[25] Farhi pg.14
F=Y*(C^-SIGMA)/P+THETA*BETA*F(+1); //[26] Farhi pg.14
Kstar=(EPSILON/(EPSILON-1))*((1+TAUL)/Astar)*(Wstar/Pstar)+THETA*BETA*Kstar(+1); //[27] Farhi pg.14
Fstar=YFstar*(Cstar^-SIGMA)/Pstar+THETA*BETA*Fstar(+1); //[28] Farhi pg.14
PD=THETA*PD(-1)*(Pi^EPSILON)+(1-THETA)*((1-THETA*(Pi^(EPSILON-1)))/(1-THETA))^(EPSILON/EPSILON-1); //[29] Home Price Dispersion
PDstar= THETA*PDstar(-1)*(Pistar^EPSILON)+(1-THETA)*((1-THETA*(Pistar^(EPSILON-1)))/(1-THETA))^(EPSILON/EPSILON-1); //[30] Foreign Price Dispersion
//-------------------Policy Rules-----------//
(1+i)=(Pi^PHIPIH)*(Y^PHIY); //[31] Domestic Policy Rule
(1+istar)=(Pistar^PHIPIH)*(YFstar^PHIY); //[32] Foreign Policy Rule
//-------------------Aggregate Constaints---------//
N=Y*PD/A; //[33] Home Aggregate Constraint
Nstar=YFstar*PDstar/Astar; //[34] Foreign Aggregate Constraint
//-------------------Market Clearing Conditions---------//
//Q=((1-ALPHA)*((S*PFstar/PH)^(ETA-1))+ALPHA)^(1/ETA-1); //[35] Home
//[36] Foreign
//-------------------Exogenous Shocks---------//
log(A) = KAPPA*log(A(-1)) + e;
log(Astar) = KAPPA*log(Astar(-1)) + estar;
log(RP)=KAPPA*log(RP(-1))+erp;
U= (log(C))-((N^(1-PHI))/(1-PHI))+BETA*U(+1);
end;
initval;
Y= 1.05086;
YFstar= 1.04467;
PH= 1.1761;
P= 0.785854;
PHstar= 1.0605;
Pstar = 0.526893;
PF = 0.580829;
PFstar = 0.526852;
Pi = 0.999844;
Pistar = 1.00096;
PiH = 1.00008;
PiF = 1;
PiHstar = 1;
PiFstar = 1.00021;
C = 1.17079;
Cstar = 1.04738;
i = 0.00980802;
istar = 0.0127093;
DF = 5.11019;
DFstar = -5.10995;
S = 1.10883;
Q = 0.743614;
W = 1.05344;
N = 1.04634;
Wstar = 0.597805;
Nstar = 1.02732;
CC = -0.0839033;
F = 3.53735;
K = 4.16102;
Fstar = 5.84907;
Kstar = 3.39894;
PD = 0.995089;
PDstar = 1.01231;
A = 0.998126;
Astar = 1.02965;
RP = 0.998604;
U = 61.3578;
end;
resid(1);
steady(solve_algo=4,maxit=10000);
resid(1);