1 Intertemporal Utility Maximization

Go to the MLX, M, PDF, or HTML version of this file. Go back to fan’s MEconTools Package, Matlab Code Examples Repository (bookdown site), or Math for Econ with Matlab Repository (bookdown site).

We previously solved for the unconstrained household’s savings and borrowing problem: unconstrained problem.

1.1 Utility Maximization over Consumption in Two Periods

  • Utility: \(U(c_1 ,c_2 )=\log (c_1 )+\beta \cdot \log (c_2 )\)

  • Budget Today: \(c_1 +b\le Z_1\)

  • Budget Tomorrow: \(c_2 \le b\cdot (1+r)+Z_2\)

  • \(c_1 >0\), \(c_2 >0\)

We have solved this problem as an unconstrained maximization problem by eliminating the consumption terms (unconstrained problem). If we keep the consumption terms but eliminatethe \(b\) term, then the problem is a constrained maximization problem with an income constraint:

  • Budget Today and Tomorrow Together: \(c_2 =(Z_1 -c_1 )(1+r)+Z_2\)

Note that we have replaced the inequality symbol by an equality symbol. The income constraints are always going to bind because households will not waste income given log utility which is always increasing in consumption. This also means we don’t have to worry about the positive consumption constraints, because households will never consume at 0 since utility is not defined. We can rewrite the budget constraint as follows:

  • Budget Today and Tomorrow Together: \(c_1 \cdot (1+r)+c_2 =Z_1 \cdot (1+r)+Z_2\)

Rewriting the problem as we do above has a nice interpretation. In this model, there is no production, endowment is fixed, and we allow the household to freely transfer resources from today to tomorrow and vice-versa. So in effect, we have two good that we are buying, \(c_1\) and \(c_2\). They seem to be the same good so they should have the same price, but they do not, because consumption in the first period is more expensive, since if you don’t consume in the first period, and save, you can earn interests and have higher \(c_2\). The price of \(c_1\) is hence \(1+r\). On the other hand, the price of \(c_2\) is just \(1\). The total resource available is on the right-hand-side of the equation. Your grandmother is transferring resources \(Z_1\) and \(Z_2\) to you, but the resources transfered in the first period is worth more because of the possibility of saving it. Again, we can bring the two periods together because the household is allowed to borrow and save. Given that we do not have uncertainty, our two period intertemporal problem has actually only one budget constraint. We can not do this for the problem with uncertainty.

The problem here is stated for \(c_1\) and \(c_2\), and is the intertemporal optimal choice problem. However, replace \(c_1\) by apples consumed today, \(c_2\) by bananas consumed today, and change the budget so that \(Z_1\) is the endowment from your grandmother who is an apple producer, and \(Z_2\) is the endowment from your other grandmother who is a banana producer. All solutions follow. We would replace \((1+r)\) by \(P_A\), the price of apples, and we can also add in \(P_B\) , the price of bananas. The key thing about building these models is that we can easily relabel variables and use the same framework to analyze different types of problems. For each type of problem, we could modify how the budget works, what is exactly in the utility function, but the structure of optimizing utility given budget is the same.

1.2 First Order Conditions of the Constrained Consumption Problem

Note again we already know the solution of this problem from: unconstrained problem. What we are doing here is to resolve the problem, but now directly for \(c_1\) and \(c_2\), rather than \(b\). But the results are the same because once you know \(b\) you know the consumption choices from the budget, and vice-versa. The solution method here is more complicated because we went from an one-choice problem in unconstrained problem to a three choice problem below. But the solution here is more general, allowing us to have addition constraints that can not be easily plugged directly into the utility function.

To solve the problem, we write down the Lagrangian, and solve a problem with three choices.

  • \(\displaystyle \mathcal{L}=\log (c_1 )+\beta \cdot \log (c_2 )-\mu \left(c_1 \cdot (1+r)+c_2 -Z_1 \cdot (1+r)-Z_2 \right)\)

We have three partial derivatives of the lagrangian, and at the optimal choices, these are true:

  • \(\frac{\partial \mathcal{L}}{\partial c_1 }=0\), then, \(\frac{1}{c_1^{\ast } }=\mu (1+r)\)

  • \(\frac{\partial \mathcal{L}}{\partial c_2 }=0\), then, \(\frac{\beta }{c_2^{\ast } }=\mu\)

  • \(\frac{\partial \mathcal{L}}{\partial \mu }=0\), then, \(c_1^{\ast } \cdot (1+r)+c_2^{\ast } =Z_1 \cdot (1+r)+Z_2\)

1.3 Optimal Relative Allocations of Consumptions in the First and Second Periods

Bringing the firs two conditions together, we have:

  1. \(\displaystyle \frac{\beta }{c_2^{\ast } }=\frac{1}{c_1^{\ast } \cdot (1+r)}\)

  2. \(\displaystyle \frac{c_1^{\ast } }{c_2^{\ast } }=\frac{1}{\beta \cdot (1+r)}\)

  3. \(\displaystyle c_1^{\ast } =\frac{1}{\beta \cdot (1+r)}\cdot c_2^{\ast }\)

Which tells us that the optimal ratio of consumption in the two periods is determined not by total resource available but by the interest rate \(r\) and preference for future \(\beta\). If the interest rate is higher, one will consume less today relative to tomorrow. If \(\beta\) is higher, which means we like the future more, one will also consume less today relative to tomorrow.

1.4 Optimal Consumption Choices

Using the third first order condition, and the optimal consumption ratio, we have:

  1. \(\displaystyle \frac{1}{\beta \cdot (1+r)}\cdot c_2^{\ast } \cdot (1+r)+c_2^{\ast } =Z_1 \cdot (1+r)+Z_2\)

  2. \(\displaystyle \frac{c_2^{\ast } }{\beta }+c_2^{\ast } =Z_1 \cdot (1+r)+Z_2\)

  3. \(\displaystyle c_2^{\ast } =\frac{Z_1 \cdot (1+r)+Z_2 }{1+\frac{1}{\beta }}\)

Now we have the optimal consumption level. If endowments in either the first or second periods are higher, the household would consume more in the second period. If the interest rate is higher, the household would consume more in the second period, if \(\beta\) moves from 1 to 0, the numerator gets larger, and the optimal choice gets smaller: this means the more you dislike to future relative to today, the less you will consume in the future.

With the solution for \(c_2^{\ast }\), we also know:

  1. \(\displaystyle c_1^{\ast } =\frac{1}{\beta \cdot (1+r)}\cdot \frac{Z_1 \cdot (1+r)+Z_2 }{1+\frac{1}{\beta }}\)

  2. \(\displaystyle c_1^{\ast } =\frac{Z_1 +Z_2 \cdot \frac{1}{1+r}}{1+\beta }\)

This means similar to the optimal choice for \(c_2\), households will consume more if endowments are higher. Now, opposite from before, if interest rate is higher, the numerator gets smaller, and the household consume less in the first period. If \(\beta\) gets closer to 0, the household will consume more today as well.

The solutions here are Marshallian.

1.5 Indirect Utility

We have a special name for the utility function when it is evaluated at the optimal choices, it is called indirect utility:

  • Indirect Utility function: \(U(c_1^{\ast } (r,Z_1 ,Z_2 ),c_2^{\ast } (r,Z_1 ,Z_2 ))=V^{\ast } (r,Z_1 ,Z_2 )\)

Given the solutions, we have:

  1. \(\displaystyle V^{\ast } (r,Z_1 ,Z_2 )=\log \left(\frac{Z_1 +Z_2 \cdot \frac{1}{1+r}}{1+\beta }\right)+\beta \cdot \log \left(\frac{Z_1 \cdot (1+r)+Z_2 }{1+\frac{1}{\beta }}\right)\)

  2. \(\displaystyle V^{\ast } (r,Z_1 ,Z_2 )=\log \left(\frac{Z_1 \cdot \left(1+r\right)+Z_2 }{\left(1+\beta \right)\cdot \left(1+r\right)}\right)+\beta \cdot \log \left(\frac{Z_1 \cdot (1+r)+Z_2 }{\left(1+\beta \right)\cdot \beta^{-1} }\right)\)

  3. \(\displaystyle V^{\ast } (r,Z_1 ,Z_2 )=\left(1+\beta \right)\log \left(\frac{Z_1 \cdot \left(1+r\right)+Z_2 }{1+\beta }\right)+\log \left(\frac{\beta^{\beta } }{1+r}\right)\)

  4. \(\displaystyle V^{\ast } (r,Z_1 ,Z_2 )=\log \left({\left(\frac{Z_1 \cdot \left(1+r\right)+Z_2 }{1+\beta }\right)}^{\left(1+\beta \right)} \cdot \left(\frac{\beta^{\beta } }{1+r}\right)\right)\)

1.6 Optimal Borrowing and Savings Choices

We can also now find the optimal borrowing and savings choice, which is, given \(c_1^{\ast } +b^{\ast } =Z_1\):

  • \(\displaystyle b^{\ast } =Z_1 -\frac{Z_1 +Z_2 \cdot \frac{1}{1+r}}{1+\beta }\)

  • \(\displaystyle b^{\ast } =\frac{\beta \cdot Z_1 -Z_2 \cdot \frac{1}{1+r}}{1+\beta }\)

You could also express the above expression as: \(b^{\ast } =\frac{\beta \cdot (1+r)\cdot Z_1 -Z_2 }{\left(1+\beta \right)\cdot \left(1+r\right)}\), which is what we obtained before from the unconstrained problem. Looking at the optimal borrowing and savings choice, we can see that sometimes the household wants to borrow, sometimes save, depending on the numerator, specifically:

  • \(b^{\ast } >0\) if \(\beta \cdot (1+r)>\frac{Z_2 }{Z_1 }\)

  • \(b^{\ast } \le 0\) if \(\beta \cdot (1+r)\le \frac{Z_2 }{Z_1 }\)

This tells us that whether a househodl borrows is dependent on the ratio of endowments: \(\frac{Z_2 }{Z_1 }\), and the discount rate multiplied by \(1+r\). The preference for future multiplied by the total return to savings must be higher than the ratio of endowment tomorrow versus today for households to want to save. In another word, suppose \(\beta \cdot (1+r)>1\), the household will be willing to save even if there is more endowment tomorrow than today.

1.7 Computational Solution to the Equality Constrained Problem

Matlab can solve the optimal choices for us. We can use diff and solve.

beta = 0.95;
z1 = 1;
z2 = 2;
r = 0.05;
syms r c1 c2 mu
% The Lagrangian
lagrangian = (log(c1) + beta*log(c2)) - mu*( c2 + (1+r)*c1 - z1*(1+r) - z2)

lagrangian =

1em \(\displaystyle \log \left(c_1 \right)+\frac{19\,\log \left(c_2 \right)}{20}-\mu \,{\left(c_2 -r+c_1 \,{\left(r+1\right)}-3\right)}\)

% Derivatives
d_lagrangian_c1 = diff(lagrangian, c1);
d_lagrangian_c2 = diff(lagrangian, c2);
d_lagrangian_mu = diff(lagrangian, mu);
GRADIENTmax = [d_lagrangian_c1; d_lagrangian_c2; d_lagrangian_mu]

GRADIENTmax =

1em \(\displaystyle \left(\begin{array}{c} \frac{1}{c_1 }-\mu \,{\left(r+1\right)}\\ \frac{19}{20\,c_2 }-\mu \\ r-c_2 -c_1 \,{\left(r+1\right)}+3 \end{array}\right)\)

% Given we have many symbols, type K, L, mu at the end to let matlab know what we are solving for
solu = solve(GRADIENTmax(1)==0, GRADIENTmax(2)==0, GRADIENTmax(3)==0, c1, c2, mu, 'Real', true);
soluC1 = (solu.c1)

soluC1 =

1em \(\displaystyle \frac{20\,{\left(r+3\right)}}{39\,{\left(r+1\right)}}\)

soluC2 = (solu.c2)

soluC2 =

1em \(\displaystyle \frac{19\,r}{39}+\frac{19}{13}\)

soluMu = (solu.mu)

soluMu =

1em \(\displaystyle \frac{39}{20\,{\left(r+3\right)}}\)

1.8 Fmincon Solution to the Constrained Problem

We can use fmincon again. What we are doing here is to explicitly solve the initially stated utility maximization problem, with both inequality constraints for consumption. This is not necessary because households would never choose consumption to be zero. Nevertheless, we can still use the fmincon set-up to solve the problem with all its constraints.

  1. \(\displaystyle c_2 +(1+r)c_1 \le Z_1 (1+r)+Z_2\)

  2. \(\displaystyle -c_1 <0\)

  3. \(\displaystyle -c_2 <0\)

To useThis is a linear system, the equations above are equal to:

  1. \(\displaystyle (1)c_2 +(1+r)c_1 \le Z_1 (1+r)+Z_2\)

  2. \(\displaystyle (0)c_2 +(-1)c_2 <0\)

  3. \(\displaystyle (-1)c_2 +(0)c_2 <0\)

Which mean that we have a \(A\) matrix and \(q\) vector:

  • \(\displaystyle \left\lbrack \begin{array}{cc} 1 & 1+r\\ 0 & -1\\ -1 & 0 \end{array}\right\rbrack \cdot \left\lbrack \begin{array}{c} c_2 \\ c_1 \end{array}\right\rbrack \le \left\lbrack \begin{array}{c} Z_1 (1+r)+Z_2 \\ 0\\ 0 \end{array}\right\rbrack\)

Now we can set up the inputs for fmincon

% Parameters
beta = 0.90;
z1 = 1;
z2 = 2;
r = 0.05;

% Write down the objective function, we will define it as a function handle, negative utility for minimization
U_neg = @(x) -1*(log(x(2)) + beta*log(x(1)));
% Constraint derived above
A = [1,1+r;0,-1;-1,0];
q = [(z1*(1+r) + z2);0;0];

Now call fminunc to solve

c_init = [0.5,0.5]; % starting value to search for optimal choice
% U_neg_num = matlabFunction(subs(U_neg, {beta, z1, z2, r}, {beta_num, z1_num, z2_num, r_num}));
[c_opti,U_neg_at_c_opti] = fmincon(U_neg, c_init, A, q);

Local minimum found that satisfies the constraints.

Optimization completed because the objective function is non-decreasing in 
feasible directions, to within the value of the optimality tolerance,
and constraints are satisfied to within the value of the constraint tolerance.

<stopping criteria details>

c2Opti = c_opti(1);
c1Opti = c_opti(2);
UatCOpti = -1*U_neg_at_c_opti;
disp(table(c1Opti, c2Opti, UatCOpti));

    c1Opti    c2Opti    UatCOpti
    ______    ______    ________

    1.5288    1.4447    0.75563 

Note that consumption in the two periods are similar. Households generally want to smooth consumption over time given their differential endowments in each period.