Leisure, Savings and Constrained Borrowing

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. And we previously solved for the constrained savings and borrowing problem for the household without labor: Constrained Household Borrowing.

What is the constrained asset choice problem with labor?

We have endowments in two periods, and . Households can choose to work or have leisure. Think about the first period as the young period, the second period as the old period (retirement). Your wage in the first period could be used for first period consumption or saved for consumption in retirement.
w is the wage, and b can be positive or negative.

Single Inequality Constraint Problem

We can formulate the constrained problem as this:
And the constraints is:
We plugged b into the utility function, so that we do not have to choose and explicitly. We also replaced leisure by in the utility. Additionally leisure will always be positive due to log utility. We have an utility maximization problem with a single inequality constraint, which is that the household can not borrow more than . Then, we would solve for the unconstrained optimal work and b choices, if the optimal unconstrained b choice is larger than , then we are done, otherwise, we solve for the optimal work choice given .
In the sections below, we:

Unconstrained Optimal Labor and Borrowing and Savings Choices Prlbme

To solve the problem, we write down the Lagrangian, and solve a problem with three choices, and let us use to represent work time:
We have two partial derivatives of the lagrangian, and at the optimal choices, these are true:
Unconstrained Choices--One Equation and One Unknown
We have two equations and two unknowns, from the two FOCs above, we have:
Then pluggint this back in to the first FOC, we have:
This is one equation and one unknown.
Unconstrained Choices--Analytical Optimal Borrowing and Savings Choice
We use Ω and χ to replace some terms above, and have:
Above we have the optimal borrowing and savings choice solution, to better interpret it, we plug Ω and χ back in
Our optimal borrowing and savings choice is:
The solution here is very similar to the solution we derived for the borrowing and savings problem earlier. Note that the key difference here is that wage and total time: are simply increasing today's endowment. When the individual prefers leisure more, the individual is more likely to borrow. We have just solved for the unconstrained optimal choices
Unconstrained Choices--Matlab Analytical Symbolic Solutions
Matlab can solve the optimal choices for us. We can use diff and solve, the solution below is identical to the solution we derived on top.
syms r z1 z2 w head b T H beta psi
% The Lagrangian
lagrangian = (log(z1 + w*H- b) + psi*log(T-H) + beta*log(z2 + b*(1+r)))
lagrangian = 
% Derivatives
d_lagrangian_b = diff(lagrangian, b);
d_lagrangian_H = diff(lagrangian, H);
GRADIENTmax = [d_lagrangian_b; d_lagrangian_H]
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, b, H, 'Real', true);
solub = simplify(solu.b)
solub = 
soluH = (solu.H)
soluH = 
Work Choice given Binding Borrowing Constraint--Matlab Analytical Symbolic Solutions
Now we solve, if the household's borrowing choice is constrained, that is the borrowing constraint binds, then the household optimizes work time choice given .
syms r z1 z2 w head bbar T H beta psi
% The Lagrangian
lagrangian = (log(z1 + w*H- bbar) + psi*log(T-H) + beta*log(z2 + bbar*(1+r)))
lagrangian = 
% Derivatives
d_lagrangian_H = diff(lagrangian, H);
GRADIENTmax = [d_lagrangian_H]
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, H, 'Real', true);
solu
solu = 

Numerical Solution to the Inequality Constraint Problem

We can formulate the constrained problem as this:
And the constraints are:
  1. , where T is total time available
We plugged b into the utility function, so that we do not have to choose and explicitly. We could also replace leisure by in the utility. Additionally leisure will always be positive due to log utility. If we did that, we have an utility maximization problem with a single inequality constraint, which is that the household can not borrow more than . Then, we would solve for the unconstrained optimal work and b choices, if the optimal unconstrained b choice is larger than , then we are done
Formulating the Constraints as a System of Linear Equations
Matlab has a conveninent function that solves any constrained maximization problem, fmincon, we used it for one choice and one constraint before:Constrained Household Borrowing. Now we have four constraints and three choice variables, we write them all as less than or equal to:
This is actually a linear system, the equations above are equal to:
Which mean that we have a A matrix and q vector:
clear all
% Parameters
beta = 0.95;
psi = 0.5;
z1 = 1;
z2 = 2;
r = 1.05;
b_bar_num = -1; % borrow up to 1 dollar
w = 2; % wage rate
T = 1; % think about time as share of time in a year
% Write down the objective function, we will define it as a function handle, negative utility for minimization
U_neg = @(x) -1*(log(z1 + w*x(2) - x(1)) + psi*log(x(3)) + beta*log(z2 + x(1)*(1+r)));
% Constraint dervied above
A = [-1,0,0;0,0,-1;0,-1,0;0,1,1];
q = [-b_bar_num;0;0;T];
b0 = [0,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}));
[x_opti,U_at_b_opti] = fmincon(U_neg, b0, 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>
b_opti = x_opti(1);
work_opti = x_opti(2);
leisure_opti = x_opti(3);
disp(table(b_opti, work_opti, leisure_opti));
b_opti work_opti leisure_opti _______ _________ ____________ 0.56595 0.59433 0.40567

Effects of ψ on optimal choices

How does optimal choice change if the preference for leisure is different? What does the optimal borrowing and savings choice stop shifting when work hour choice constraint becomes binding?
% Create a vector of Z2, so Z2 fector starts at the same value as Z1*0.5 going up to 4 times Z1
psi_vec = linspace(0, 3, 20);
% A vector to store optimal choices
b_opti_vec = zeros(size(psi_vec));
work_opti_vec = zeros(size(psi_vec));
leisure_opti_vec = zeros(size(psi_vec));
% Solving for optimal choices as we change Z2
for i=1:1:length(psi_vec)
U_neg = @(x) -1*(log(z1 + w*x(2) - x(1)) + psi_vec(i)*log(x(3)) + beta*log(z2 + x(1)*(1+r)));
options = optimoptions('FMINCON','Display','off');
[x_opti,U_at_x_opti] = fmincon(U_neg, b0, A, q, [], [], [], [], [], options);
b_opti_vec(i) = x_opti(1);
work_opti_vec(i) = x_opti(2);
leisure_opti_vec(i) = x_opti(3);
end
 
% Plot Results
figure()
subplot(2,2,1)
plot(psi_vec, b_opti_vec)
ylim([-1.1 1]);
hold on
plot(psi_vec,ones(size(psi_vec)) * 0, 'k-.');
plot(psi_vec,ones(size(psi_vec)) * -1, 'k--');
grid on;
title('Borrowing/Savings')
ylabel('Optimal Savings Choice')
xlabel('psi, leisure preference')
subplot(2,2,2)
plot(psi_vec, work_opti_vec)
ylim([-0.1 1.1]);
hold on;
plot(psi_vec,ones(size(psi_vec)) * 1, 'k--');
plot(psi_vec,ones(size(psi_vec)) * 0, 'k--');
grid on;
title('Work')
ylabel('Share of Time Working')
xlabel('psi, leisure preference')
subplot(2,2,3)
plot(psi_vec, leisure_opti_vec)
ylim([-0.1 1.1]);
hold on;
plot(psi_vec,ones(size(psi_vec)) * 1, 'k--');
plot(psi_vec,ones(size(psi_vec)) * 0, 'k--');
grid on;
title('Leisure')
ylabel('Share of Time Leisure')
xlabel('psi, leisure preference')

Effects of r and on optimal choices

How does optimal choice change if the household has more endowment tomorrow and what if interest rate changes? See double loop below.
% Vector of interest rates
r_vec = linspace(0.4, 1.50, 20);
% Vector of Z2
Z2_vec = linspace(z1*1, z1*3, 2);
% A vector to store optimal choices
rows = length(r_vec);
cols = length(Z2_vec);
b_opti_mat = zeros(rows, cols);
work_opti_mat = zeros(rows, cols);
leisure_opti_mat = zeros(rows, cols);
% Solving for optimal choices as we change Z2
for j=1:1:length(Z2_vec)
for i=1:1:length(r_vec)
U_neg = @(x) -1*(log(z1 + w*x(2) - x(1)) + psi*log(x(3)) + beta*log(Z2_vec(j) + x(1)*r_vec(i)));
options = optimoptions('FMINCON','Display','off');
[x_opti,U_at_x_opti] = fmincon(U_neg, b0, A, q, [], [], [], [], [], options);
b_opti_mat(i, j) = x_opti(1);
work_opti_mat(i, j) = x_opti(2);
leisure_opti_mat(i, j) = x_opti(3);
end
end
 
% Plot Results
legendCell = cellstr(num2str(Z2_vec', 'Z2=%-d'));
figure()
subplot(2,2,1)
plot(r_vec, b_opti_mat)
ylim([-1.1 1]);
hold on
plot(r_vec,ones(size(r_vec)) * 0, 'k-.');
plot(r_vec,ones(size(r_vec)) * -1, 'k--');
grid on;
title('Borrowing/Savings')
ylabel('Optimal Savings Choice')
xlabel('interest rate')
legend(legendCell, 'Location','northwest');
subplot(2,2,2)
plot(r_vec, work_opti_mat)
ylim([-0.1 1.1]);
hold on;
plot(r_vec,ones(size(r_vec)) * 1, 'k--');
plot(r_vec,ones(size(r_vec)) * 0, 'k--');
grid on;
title('Work')
ylabel('Share of Time Working')
xlabel('interest rate')
legend(legendCell);
subplot(2,2,3)
plot(r_vec, leisure_opti_mat)
ylim([-0.1 1.1]);
hold on;
plot(r_vec,ones(size(r_vec)) * 1, 'k--');
plot(r_vec,ones(size(r_vec)) * 0, 'k--');
grid on;
title('Leisure')
ylabel('Share of Time Leisure')
xlabel('interest rate')
legend(legendCell);