forked from dgevans/Golosov-Sargent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SolveImpCons.m
executable file
·36 lines (30 loc) · 980 Bytes
/
SolveImpCons.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function [ceq] = SolveImpCons(c1,R,u2btild,s,Para)
% This function solves the implemetability conndition for c1 given x,R. We
% first express c2,l1,l2 in c1 and then use the result that
% u2btild=u2btildprime
% Detailed explanation goes here
n1=Para.n1;
n2=Para.n2;
g=Para.g(s);
theta_1=Para.theta_1;
theta_2=Para.theta_2;
psi=Para.psi;
beta=Para.beta;
c2=R^(-1)*c1;
% Solve for l1 , l2 using the resource constraint and wage equation
TotalResources=(c1*n1+c2*n2+g);
FF=R*theta_2/theta_1;
DenL2=n1*theta_1*FF+theta_2*n2;
l2=(TotalResources-n1*theta_1+n1*theta_1*FF)/(DenL2);
if theta_2==0
l1=TotalResources/(n1*theta_1);
l2=0;
else
l1= 1-FF*(1-l2);
end
BracketTerm=l2/(1-l2)-(l1/(1-l1))*R;
cUpperBound=(theta_1*n1*FF+theta_2*n2-theta_1*n1*(FF-1)-g)/(n1+n2/R);
% Nonlinear equality constraints - Imp Cons
%ceq = (c2-c1)-((1-psi)/psi)*((l2*c2)/(1-l2)-(l1*c1)/(1-l1))-(c2/psi)*u2btild*(1/beta-1);
ceq = 1-R+u2btild/psi-((1-psi)/(psi))*BracketTerm-u2btild/(beta*psi);
end