Undergraduate Computational Macro
Let \(Y_t\) be the stochastic payoffs of the consumer
Let \(u(\cdot)\) be a standard utility function with \(u'(\cdot) > 0\) and \(u''(\cdot) \leq 0\)
Preferences over stochastic incomes \(\{Y_{t+j}\}_{j=0}^\infty\) given time \(t\) information are
\[ \mathbb{E}_t \sum_{j=0}^\infty \beta^j u(Y_{t+j}) \]
We will try to rewrite this recursively just as we did when calculating PDVs
The worker faces a trade-off:
To decide optimally in the face of this trade off, we use dynamic programming
The key is to start with the state:
Then determine the feasible set of actions, and how the state evolves under each action
The value function for the unemployed worker is
\[ \begin{aligned} U &= u(c) + \beta \left[ (1-\gamma) U + \gamma \mathbb{E}[\max\{U, V(w')\}]\right]\\ &= u(c) + \beta \left[ (1-\gamma) U + \gamma \sum_{i=1}^N \max\{U, V(w_i)\} p_i \right] \end{aligned} \]
The value function for the employed worker is
\[ V(w) = u(w) + \beta \left[ (1-\alpha) V(w) + \alpha U \right] \]
These are the Bellman Equations for the McCall model
Since there are only \(N\) values of \(w_i\), we can define \(V(w_i) \equiv V_i\) and solve for \(N+1\) values (i.e., \(V_1, \ldots, V_N, U\))
Let \(X \equiv \begin{bmatrix} V_1 & \ldots & V_N & U \end{bmatrix}^{\top}\)
Define the Bellman Operator \(T : \mathbb{R}^{N+1} \to \mathbb{R}^{N+1}\) stacking Bellman Equations \[ T(X) \equiv \begin{bmatrix} u(w_1) + \beta \left[ (1-\alpha) V_1 + \alpha U \right] \\ \vdots \\ u(w_N) + \beta \left[ (1-\alpha) V_N + \alpha U \right] \\ u(c) + \beta \left[ (1-\gamma) U + \gamma \sum_{i=1}^N \max\{U, V_i\} p_i \right] \end{bmatrix} \]
Then the fixed point of \(T(\cdot)\) (i.e., \(T(X) = X\)) is the solution to the problem
The \(V(w)\) is now the value of having a wage offer, not of choosing to work at that offer \[ \begin{aligned} V(w) = \max\{&u(w) + \beta \left[ (1-\alpha) V(w) + \alpha V(0) \right],\\ & u(c) + \beta \left[ (1-\gamma) V(0) + \gamma \mathbb{E}(V(w'))\right]\} \end{aligned} \]
Let \(\bar{w}\) the minimum \(w_i\) such that
\[ u(w_i) + \beta \left[ (1-\alpha) V(w_i) + \alpha V(0) \right] > u(c) + \beta \left[ (1-\gamma) V(0) + \gamma \mathbb{E}(V(w'))\right] \]
Then we can interpret this as the reservation wage. If the \(w'\) were distributed continuously, then it might be an exact wage at equality
With this, the \(\bar{w}\) will be a kink in the \(V(w)\) function at \(\bar{w}\)
\[ p(y) = u(y) + \beta \mathbb{E}\left[p(y') | y\right] \]
But there are only 2 possible states, so \(p \equiv \begin{bmatrix}p_L & p_H \end{bmatrix}^{\top} \in \mathbb{R}^2\)
Rewriting this as a system of equations \[ \begin{aligned} p_L &= u(y_L) + \beta \mathbb{E}\left[p(y') | y_L\right] = u(y_L) + \beta \left[ (1-\alpha) p_L + \alpha p_H \right]\\ p_H &= u(y_H) + \beta \mathbb{E}\left[p(y') | y_H\right] = u(y_H) + \beta \left[ \gamma p_L + (1-\gamma) p_H \right] \end{aligned} \]
Stack \(p \equiv \begin{bmatrix} p_L & p_H \end{bmatrix}^{\top}\) and \(u_y \equiv \begin{bmatrix} u(y_L) & u(y_H) \end{bmatrix}^{\top}\)
\[ p = u_y + \beta \begin{bmatrix} 1 - \alpha & \alpha \\ \gamma & 1-\gamma \end{bmatrix} p\equiv T(p) \]
Then the fixed point of \(T(\cdot)\) (i.e., \(T(p) = p\)) is the solution to the problem
y = [3.0, 5.0] #y_L, y_H
sigma = 0.5
u_y = (y.^(1-sigma) .- 1) / (1-sigma) # CRRA utility
beta = 0.95
alpha = 0.2
gamma = 0.5
iv = [0.8, 0.8]
A = [1-alpha alpha; gamma 1-gamma]
sol = fixedpoint(p -> u_y .+ beta * A * p, iv) # T(p) := u_y + beta A p
p_L, p_H = sol.zero # can unpack a vector
@show p_L, p_H, sol.iterations
@show (I - beta * A) \ u_y;
(p_L, p_H, sol.iterations) = (34.63941760551734, 36.0492558430863, 4)
(I - beta * A) \ u_y = [34.63941760551725, 36.04925584308623]
function mccall_model(;
alpha = 0.2, # prob lose job
beta = 0.98, # discount rate
gamma = 0.7, # prob job offer
c = 6.0, # unemployment compensation
sigma = 2.0, # CRRA parameters
w = range(10, 20, length = 60), # wage values
p = pdf.(BetaBinomial(59, 600, 400), 0:length(w)-1)) # probs for each wage
# why the c <= 0 case? Makes it easier when finding equilibrium
u(c, sigma) = c > 0 ? (c^(1 - sigma) - 1) / (1 - sigma) : -10e-6
u_c = u(c, sigma)
u_w = u.(w, sigma)
return (; alpha, beta, sigma, c, gamma, w, p, u_w, u_c)
end
The value function for the unemployed worker is
\[ \begin{aligned} U &= u(c) + \beta \left[ (1-\gamma) U + \gamma \mathbb{E}[\max\{U, V(w')\}]\right]\\ &= u(c) + \beta \left[ (1-\gamma) U + \gamma \sum_{i=1}^N \max\{U, V(w_i)\} p_i \right] \end{aligned} \]
The value function for the employed worker is
\[ V(w) = u(w) + \beta \left[ (1-\alpha) V(w) + \alpha U \right] \]
These are the Bellman Equations for the McCall model
function T(X;mcm)
(;alpha, beta, gamma, c, w, p, u_w, u_c) = mcm
V = X[1:end-1]
U = X[end]
V_p = u_w + beta * ((1 - alpha) * V .+ alpha * U)
# Or, expanding out with a comprehension
# V_p = [ u_w[i] + beta * ((1 - alpha) * V[i] + alpha * U) for i in 1:length(w)]
U_p = u_c + beta * (1 - gamma) * U + beta * gamma * sum(max(U, V[i]) * p[i] for i in 1:length(w))
return [V_p; U_p]
end
function solve_mccall_model(mcm; U_iv = 1.0, V_iv = ones(length(mcm.w)), tol = 1e-5, iter = 2_000)
(; alpha, beta, sigma, c, gamma, w, sigma, p) = mcm
x_iv = [V_iv; U_iv] # initial x val
xstar = fixedpoint(X -> T(X;mcm), x_iv, iterations = iter, xtol = tol, m = 0).zero
V = xstar[1:end-1]
U = xstar[end]
# compute the reservation wage
wbarindex = searchsortedfirst(V .- U, 0.0)
if wbarindex >= length(w) # if this is true, you never want to accept
w_bar = Inf
else
w_bar = w[wbarindex] # otherwise, return the number
end
return (;V, U, w_bar)
end
mcm = mccall_model()
sol = solve_mccall_model(mcm)
plot(mcm.w, sol.V; label = L"V(c=6.0)",
xlabel=L"w", size=(600, 400))
hline!(mcm.w, [sol.U], label=L"U(c=6.0)")
vline!([sol.w_bar];
label = L"\bar{w}(c=6.0)")
mcm2 = mccall_model(c = 8.0)
sol2 = solve_mccall_model(mcm2)
plot!(mcm2.w, sol2.V; label = L"V(c=8.0)",
linestyle = :dash)
hline!(mcm2.w, [sol2.U], label=L"U(c=8.0)",
linestyle = :dash,)
vline!([sol2.w_bar]; linestyle = :dash,
label = L"\bar{w}(c=8.0)")
mcm = mccall_model(;alpha = 0.0)
sol = solve_mccall_model(mcm)
plot(mcm.w, sol.V; label = L"V(c=6.0)",
xlabel=L"w", size=(600, 400))
hline!(mcm.w, [sol.U], label=L"U(c=6.0)")
vline!([sol.w_bar];
label = L"\bar{w}(c=6.0)")
mcm2 = mccall_model(;c = 8.0, alpha = 0.0)
sol2 = solve_mccall_model(mcm2)
plot!(mcm2.w, sol2.V; label = L"V(c=8.0)",
linestyle = :dash)
hline!(mcm2.w, [sol2.U], label=L"U(c=8.0)",
linestyle = :dash,)
vline!([sol2.w_bar]; linestyle = :dash,
label = L"\bar{w}(c=8.0)")
mcm = mccall_model()
sol = solve_mccall_model(mcm)
plot(mcm.w, sol.V; label = L"V(\alpha=0.2)",
xlabel=L"w", size=(600, 400))
hline!(mcm.w,[sol.U],label=L"U(\alpha=0.2)")
vline!([sol.w_bar];
label = L"\bar{w}(\alpha=0.2)")
mcm2 = mccall_model(;alpha = 0.3)
sol2 = solve_mccall_model(mcm2)
plot!(mcm2.w,sol2.V; label=L"V(\alpha=0.3)",
linestyle = :dash)
hline!(mcm2.w,[sol2.U],label=L"U(\alpha=0.3)",
linestyle = :dash,)
vline!([sol2.w_bar]; linestyle = :dash,
label = L"\bar{w}(\alpha=0.3)")
Unemployment insurance is a transfer from the government to the unemployed
We will assume that:
If there are a normalized measure \(1\) in the economy, then the government budget constraint is
\[ \tau = \bar{u} c \]
Given that the consumer values their wage or unemployment with \(V(w)\) and \(U\), a benevolent planner would use the same criteria
Let \(\bar{e}\) and \(\bar{u}\) be the steady state fraction of employed and unemployed individuals
Since consumers would never accept a \(w < \bar{w}\) we know the wage distribution conditional on being employed is
\[ \mathbb{P}(w_i | w_i > \bar{w}) = \frac{p_i}{\sum_{j=i}^N p_j} \]
function lake_model(; lambda = 0.283, alpha = 0.013, b = 0.0124, d = 0.00822)
g = b - d
A = [(1 - lambda) * (1 - d)+b (1 - d) * alpha+b
(1 - d)*lambda (1 - d)*(1 - alpha)]
A_hat = A ./ (1 + g)
x_0 = ones(size(A_hat, 1)) / size(A_hat, 1)
sol = fixedpoint(x -> A_hat * x, x_0)
converged(sol) || error("Failed to converge in $(sol.iterations) iter")
x_bar =sol.zero
return (; lambda, alpha, b, d, A, A_hat, x_bar)
end
function compute_optimal_quantities(c_pretax, tau; p, sigma, gamma, beta, alpha, w_pretax, b, d)
c = c_pretax - tau
w = w_pretax .- tau
mcm = mccall_model(; alpha, beta, gamma, sigma, p, c, w)
(; V, U, w_bar) = solve_mccall_model(mcm)
accept_wage = w .> w_bar # indices of accepted wages
prop_accept = dot(p, accept_wage) # proportion of accepted wages
lambda = gamma * prop_accept
lm = lake_model(; lambda, alpha, b, d)
u_bar, e_bar = lm.x_bar
V_wealth = (dot(p, V .* accept_wage)) / dot(p, accept_wage)
welfare = e_bar .* V_wealth + u_bar .* U
return (;w_bar, lambda, V, U, u_bar, e_bar, welfare)
end
function find_balanced_budget_tax(c_pretax; p, sigma, gamma, beta, alpha, w_pretax, b, d)
function steady_state_budget(tau)
(;u_bar, e_bar) = compute_optimal_quantities(c_pretax, tau; p, sigma, gamma, beta,
alpha, w_pretax, b, d)
return tau - u_bar * c_pretax
end
# Find root
tau = find_zero(steady_state_budget, (0.0, 0.9 * c_pretax))
return tau
end
alpha = (1 - (1 - 0.013)^3)
b = 0.0124
d = 0.00822
beta = 0.98
gamma = 1.0
sigma = 2.0
# Discretized log normal
log_wage_mean = 20
wage_grid_size = 200
w_pretax = range(1e-3, 170,
length = wage_grid_size + 1)
wage_dist = LogNormal(log(log_wage_mean), 1)
p = pdf.(wage_dist, w_pretax)
p = p ./ sum(p)
plot(w_pretax, p; xlabel = "Pretax Wage",
label = "PMF", size = (600, 400))
function calculate_equilibriums(c_pretax; p, sigma, gamma, beta, alpha, w_pretax, b, d)
tau_vec = similar(c_pretax)
u_vec = similar(c_pretax)
e_vec = similar(c_pretax)
welfare_vec = similar(c_pretax)
for (i, c_pre) in enumerate(c_pretax)
tau = find_balanced_budget_tax(c_pre; p, sigma, gamma, beta,alpha, w_pretax, b, d)
(;u_bar, e_bar, welfare) = compute_optimal_quantities(c_pre, tau; p, sigma, gamma, beta,alpha,
w_pretax,b, d)
tau_vec[i] = tau
u_vec[i] = u_bar
e_vec[i] = e_bar
welfare_vec[i] = welfare
end
return tau_vec, u_vec, e_vec, welfare_vec
end
# levels of unemployment insurance we wish to study
c_pretax = range(5, 140, length = 60)
tau_vec, u_vec, e_vec, welfare_vec = calculate_equilibriums(c_pretax; p, sigma, gamma, beta,alpha,
w_pretax, b, d)
# plots
plt_unemp = plot(title = "Unemployment", c_pretax, u_vec, color = :blue, xlabel = "c", label = "")
plt_tax = plot(title = "Tax", c_pretax, tau_vec, color = :blue, xlabel = "c", label = "")
plt_emp = plot(title = "Employment", c_pretax, e_vec, color = :blue, xlabel = "c", label = "")
plt_welf = plot(title = "Welfare", c_pretax, welfare_vec, color = :blue, xlabel = "c", label = "")
plot(plt_unemp, plt_emp, plt_tax, plt_welf, layout = (2, 2))