Application Center - Maplesoft

# Intertemporal Consumption Dynamics

You can switch back to the summary page by clicking here.

 > # Intertemporal Consumption dynamics

 >

 > ###################### Slope Indifference Curve ###################

 > restart:

 >

 > # Our General intertemporal utility function is given by

 > U:=F(c1(t),c2(t));

 (1)

 > # where c1 is consumtion in period 1 amd c2 is consumption in period 2

 >

 > # The derivative with respect to time (multivariable chain rule) for the above function is given by

 > dU=diff(F(c1,c2),c1)*diff(c1(t),t)+diff(F(c1,c2),c2)*diff(c2(t),t);

 (2)

 > # We now note that any movement along the same indifference curve (also called a isoquant or contour line)

 > # means that the change in U is equal to zero, dQ=0. The increase in U due to an increase in c1 is

 > # completly offset by the decrease in U due to an decrease in c2

 >

 > subs(dU=0,%);

 (3)

 > isolate(%,diff(c2(t),t));

 (4)

 > %/diff(c1(t),t);

 (5)

 > # We note that

 > # diff(F(c1, c2), c1)= Marginal Utility with respect to c1 (MU_c1) and

 > # diff(F(c1, c2), c2)= Marginal Utility with respect to c2 (MU_c2)

 >

 > # Note that MU_c1 is the extra utility we get from one extra unit of c1 and

 > # MU_c2 is the extra utility we get from one extra unit of c2

 >

 > subs({diff(F(c1, c2), c1)= MU_c1, diff(F(c1, c2), c2)= MU_c2},%);

 (6)

 > ######################################################################

 >

 > # We now note that diff(c2(t),t)=c2(t+1)-c2(t) and diff(c1(t),t)=c1(t+1)-c1(t)

 >

 > # Which means that

 > diff(c2(t),t)/diff(c1(t),t)=(c2(t+1)-c2(t))/(c1(t+1)-c1(t));

 (7)

 > # Since the slope of a function is defined as

 > slope=(y(t+1)-y(t))/(x(t+1)-x(t));

 (8)

 > # we can write

 > diff(c2(t),t)/diff(c1(t),t)=slope;

 (9)

 > ########################################################################

 >

 > # If we substitute that into the previous equation we get

 > slope_indifference_curve:=-MU_c1/MU_c2;

 (10)

 >

 > ###################### Slope Budget Constraint ###################

 >

 > # Our budget constraint is given by

 > I=P_c1*c1+P_c2*c2;

 (11)

 > isolate(%,c1);

 (12)

 > collect(%,c2);

 (13)

 > sort(%,I);

 (14)

 > # The slope of the budget constraint is therefore given by - P_c2/P_c1

 > slope_budget_constraint:=- P_c2/P_c1;

 (15)

 >

 > ####################### Optimality ###################

 >

 > # For optimality the slope of the indifference curve has to

 > # be equal to the slope of the budget constraint

 > slope_indifference_curve=slope_budget_constraint;

 (16)

 >

 > ##############################################################

 >

 > ################ Utility Example-1: Basic  ##############

 >

 > ########### Slope Utility Function

 >

 > restart;

 > # Our Utility function is given by the equation below

 > U:=u(c1)+B*u(c2);

 (17)

 > # where c1 is consumption period 1 and c2 is consumption period 2

 > # note that consumption in period 2 c2 is discounted. We therefor have

 > # Bu(c2) where B=1/(1+p) where p is a time preference parameter

 >

 > # Our marginal utility with respect to c1 is given by

 > MU_c1=diff(U,c1);

 (18)

 > # Our marginal utility with respect to c2 is given by

 > MU_c2=diff(U,c2);

 (19)

 > # The indifference curve slope is therefore given by

 > MRS:=-rhs(%%)/rhs(%);

 (20)

 > # Which can be written as

 > slope_ind:= - u?(c1)/ (B*u?(c2));

 (21)

 >

 > ########### Slope Budget Constraint

 >

 > restart;

 > # Our budget constraint is given by

 > c1+c2/(1+r)=w1+ w2/(1+r);

 (22)

 > %-c1;

 (23)

 > %*(1+r);

 (24)

 > # Which can be written as

 > c2 = (1+r)*w1+(1+r)*w2/(1+r)-(1+r)*c1;

 (25)

 > # We define the intercept alpha=(1+r)*w1+w2 so we get

 > c2=alpha-(1+r)*c1;

 (26)

 > # Which means that the slope of the budget constraint

 > # is given by - P_c2/P_c1 = -(1+r)

 >

 >

 > ########### Optimality

 >

 > # Again for optimality the slope of the indifference curve has to

 > # be equal to the slope of the budget constraint

 >

 > # Slope indifference curve is given by

 > slope_ind:= - u?(c1)/ (B*u?(c2));

 (27)

 > # Slope budget constraint is given by

 > slope_bud:= -(1+r);

 (28)

 > %=%%;

 (29)

 > %*(-1);

 (30)

 > %*B;

 (31)

 > # we note that B=1/(1+p) so we get

 > subs(B=1/(1+p),%);

 >

 (32)

 >

 >

 > ################ Utility Example-2: Two Period Lagrangian  ##############

 >

 > restart;

 > # The Lagrangian is given by

 > L:=u(c1)+B*u(c2)+lambda*(w1+ w2/(1+r)-c1- c2/(1+r)) ;

 (33)

 > # where B=1/(1+p) where p is a time preference parameter and r is the interest rate

 > ## foc_1

 > diff(L,c1)=0;

 (34)

 > isolate(%, lambda );

 (35)

 > A_:=subs(diff(u(c1),c1)=u?(c1),%);

 (36)

 > ## foc_2

 > diff(L,c2)=0;

 (37)

 > isolate(%, lambda );

 (38)

 > B_:=subs(diff(u(c2),c2)=u?(c2),%);

 (39)

 > # Combining A and B

 >

 > A_;

 (40)

 > B_;

 (41)

 > rhs(%%)=rhs(%);

 (42)

 > # divide both sides by u?(c2)

 > %/`u?`(c2);

 (43)

 > # we note that B=1/(1+p) so we get

 > subs(B=1/(1+p),%);

 (44)

 > # Which is the same expression we had previously

 >

 >

 >

 > ########## Utility Example-3: Four Period Lagrangian with CIES Utility  ##############

 >

 > restart;

 > # The Lagrangian is given by

 > L:=U(c1,c2,c3,c4)+lambda*(w1+ w2/(1+r)+w3/(1+r)^2+w3/(1+r)^3-c1- c2/(1+r) -c3/(1+r)^2 - c4/(1+r)^3  ) ;

 (45)

 >

 > ## foc_1

 >

 > diff(L,c1)=0;

 (46)

 > isolate(%, lambda );

 (47)

 > subs(diff(U(c1,c2,c3,c4),c1)=U?(c1),%);

 (48)

 > # Our utility function is given by

 > U(c1,c2,c3,c4)=(c1^(1-σ)-1)/(1-σ)+B^1*(c2^(1-σ)-1)/(1-σ)+B^2*(c3^(1-σ)-1)/(1-σ)+B^3*(c4^(1-σ)-1)/(1-σ);

 (49)

 > U?(c1)=simplify(diff(rhs(%),c1));

 (50)

 > # which gives us

 > A_:=lambda=rhs(%);

 (51)

 >

 > ## foc_2

 >

 > diff(L,c2)=0;

 (52)

 > isolate(%, lambda );

 (53)

 > subs(diff(U(c1,c2,c3,c4),c2)=U?(c2),%);

 (54)

 > # Again our utility function is given by

 > U(c1,c2,c3,c4)=(c1^(1-σ)-1)/(1-σ)+B^1*(c2^(1-σ)-1)/(1-σ)+B^2*(c3^(1-σ)-1)/(1-σ)+B^3*(c4^(1-σ)-1)/(1-σ);

 (55)

 > U?(c2):=simplify(diff(rhs(%),c2));

 (56)

 > # which gives us

 > B_:=lambda=B*c2^(-sigma)*(1+r);

 (57)

 >

 > # Combining foc_1 and foc_2

 >

 > A_;

 (58)

 > B_;

 (59)

 > rhs(%%)=rhs(%);

 (60)

 > # divide both sides by c2^(-sigma)

 > %/c2^(-sigma) ;

 (61)

 > simplify(%);

 (62)

 > # which can be written as

 > (c2/c1)^sigma=rhs(%);

 (63)

 > # raise both sides by 1/sigma

 > lhs(%)^(1/sigma)=rhs(%)^(1/sigma);

 (64)

 > simplify( lhs(%), 'symbolic' )=rhs(%);

 (65)

 > A_2:=%*c1;

 (66)

 >

 > ## foc_3

 >

 > diff(L,c3)=0;

 (67)

 > isolate(%, lambda );

 (68)

 > subs(diff(U(c1,c2,c3,c4),c3)=U?(c3),%);

 (69)

 > # Our utility function is given by

 > U(c1,c2,c3,c4)=(c1^(1-σ)-1)/(1-σ)+B^1*(c2^(1-σ)-1)/(1-σ)+B^2*(c3^(1-σ)-1)/(1-σ)+B^3*(c4^(1-σ)-1)/(1-σ);

 (70)

 > U?(c3)=simplify(diff(rhs(%),c3));

 (71)

 > # which gives us

 > C_:=lambda=rhs(%)*(1+r)^2;

 (72)

 >

 >

 > # Combining foc_2 and foc_3

 >

 > B_;

 (73)

 > C_;

 (74)

 > rhs(%%)=rhs(%);

 (75)

 > %/(B*(1+r));

 (76)

 > # divide both sides by c3^(-sigma)

 > lhs(%)/c3^(-sigma)=rhs(%)/c3^(-sigma) ;

 (77)

 > simplify(%);

 (78)

 > # which can be written as

 > (c3/c2)^sigma=B*(1+r);

 (79)

 > # raise both sides by 1/theta

 > lhs(%)^(1/sigma)=rhs(%)^(1/sigma);

 (80)

 > simplify( lhs(%), 'symbolic' )=rhs(%);

 (81)

 > A_3:=%*c2;

 (82)

 >

 > ## foc_4

 >

 > diff(L,c4)=0;

 (83)

 > isolate(%, lambda );

 (84)

 > subs(diff(U(c1,c2,c3,c4),c4)=U?(c4),%);

 (85)

 > # Our utility function is given by

 > U(c1,c2,c3,c4)=(c1^(1-σ)-1)/(1-σ)+B^1*(c2^(1-σ)-1)/(1-σ)+B^2*(c3^(1-σ)-1)/(1-σ)+B^3*(c4^(1-σ)-1)/(1-σ);

 (86)

 > U?(c3)=simplify(diff(rhs(%),c4));

 (87)

 > # which gives us

 > D_:=lambda=rhs(%)*(1+r)^3;

 (88)

 >

 > # Combining foc_3 and foc_4

 >

 > C_;

 (89)

 > D_;

 (90)

 > rhs(%%)=rhs(%);

 (91)

 > %/(B^2*(1+r)^2);

 (92)

 > # divide both sides by c4^(-sigma)

 > lhs(%)/c4^(-sigma)=rhs(%)/c4^(-sigma) ;

 (93)

 > simplify(%);

 (94)

 > # which can be written as

 > (c4/c3)^sigma=B*(1+r);

 (95)

 > # raise both sides by 1/theta

 > lhs(%)^(1/sigma)=rhs(%)^(1/sigma);

 (96)

 > simplify( lhs(%), 'symbolic' )=rhs(%);

 (97)

 > A_4:=%*c3;

 (98)

 >

 > # Summary Consumption Period 1-4

 >

 > # we assume that the first period consumption is given by

 > c1:=100;

 (99)

 > A_2;

 (100)

 > A_3;

 (101)

 > A_4;

 (102)

 >

 >

 > ################ Utility Example-4: General Decay Consumption  ##############

 >

 > restart;

 >

 > # Our general equation looks like

 > c_(t+1)=c_(t)*(B(1+r))^(1/sigma);

 (103)

 > # we assume the following parameter values

 > subs({B=0.85,sigma=2, r=0.4},%);

 (104)

 > simplify(%);

 (105)

 > ########### Stability and Fixed point

 > # Since the slope is +0.9 we will have a stable equilibrium

 > %-c_(t);

 (106)

 > # fixed point c_(t+1)-c_(t)=0

 > subs(c_(t+1)-c_(t)=0,%);

 (107)

 > solve(%,c_(t));

 (108)

 > # This means that our fixed point is 0

 > ##########################################

 >

 >

 > Digits := 6:

 >

 > # We now assume that the starting value of c(t) is 100

 > c(1)=100;

 (109)

 > # c(2) is therefore given by

 > c(2)=0.92*rhs(%);

 (110)

 > # c(3) is therefore given by

 > c(3)=0.92*rhs(%);

 (111)

 > # c(4) is therefore given by

 > c(4)=0.92*rhs(%);

 (112)

 > # c(5) is therefore given by

 > c(5)=0.92*rhs(%);

 (113)

 >

 > # We can solve the above recursive equation much

 > # easier by using the below procedure

 >

 > c[1]:=100:

 > for n from 2 to 120 do c[n] := 0.92*c[n-1]   end do:

 > C:=[seq(c[i],i=1..120)];

 (114)

 > with(Statistics):

 > PointPlot(C, color = black, thickness = 3, symbol = soliddiamond, symbolsize = 20,labels=[t, c], view=[0..120, 0..100]);

 > # We can see that over time c is approach the fixed point 0

Legal Notice: The copyright for this application is owned by the authors. Neither Maplesoft nor the authors are responsible for any errors contained within and are not liable for any damages resulting from the use of this material.. This application is intended for non-commercial, non-profit use only. Contact the authors for permission if you wish to use this application in for-profit activities.