Intertemporal Utility Maximization

Back to Intro Math for Econ, Matlab Examples, or MEconTools Repositories
We previously solved for the unconstrained household's savings and borrowing problem: unconstrained problem.

Utility Maximization over Consumption in Two Periods

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:
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:
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, and . 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 . The price of is hence . On the other hand, the price of is just 1. The total resource available is on the right-hand-side of the equation. Your grandmother is transferring resources and 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 and , and is the intertemporal optimal choice problem. However, replace by apples consumed today, by bananas consumed today, and change the budget so that is the endowment from your grandmother who is an apple producer, and is the endowment from your other grandmother who is a banana producer. All solutions follow. We would replace by , the price of apples, and we can also add in , 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.

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 and , 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.
We have three partial derivatives of the lagrangian, and at the optimal choices, these are true:

Optimal Relative Allocations of Consumptions in the First and Second Periods

Bringing the firs two conditions together, we have:
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 β. If the interest rate is higher, one will consume less today relative to tomorrow. If β is higher, which means we like the future more, one will also consume less today relative to tomorrow.

Optimal Consumption Choices

Using the third first order condition, and the optimal consumption ratio, we have:
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 β 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 , we also know:
This means similar to the optimal choice for , 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 β gets closer to 0, the household will consume more today as well.
The solutions here are Marshallian.

Indirect Utility

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

Optimal Borrowing and Savings Choices

We can also now find the optimal borrowing and savings choice, which is, given :
You could also express the above expression as: , 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:
This tells us that whether a househodl borrows is dependent on the ratio of endowments: , and the discount rate multiplied by . 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 , the household will be willing to save even if there is more endowment tomorrow than today.

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 = 
% 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 = 
% 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 = 
soluC2 = (solu.c2)
soluC2 = 
soluMu = (solu.mu)
soluMu = 

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.
To useThis is a linear system, the equations above are equal to:
Which mean that we have a A matrix and q vector:
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.