Undergraduate Computational Macro
\[ x_{t+1} = h(x_t) \]
\[ x_{t+1} = a x_t + b \] For constants \(a\) and \(b\). Iterating, \[ \begin{aligned} x_1 &= h(x_0) = a x_0 + b\\ x_2 &= h(h(x_0)) = a (a x_0 + b) + b = a^2 x_0 + a b + b\\ x_3 &= a(a^2 x_0 + a b + b) + b = a^3 x_0 + a^2 b + a b + b\\ \ldots & \\ x_t &= b \sum_{j=0}^{t-1} a^j + a^t x_0 = b \frac{1 - a^t}{1 - a} + a^t x_0 \end{aligned} \]
In this economy, output is produced by combining labor and capital
Labor \(N_t\), which we assume is supplied inelastically
Capital, \(K_t\), which is accumulated over time
In addition, total factor productivity (TFP), \(z_t\), is the technological level in the economy
The physical output from operating the technology is:
\[ Y_t = z_t F(K_t, N_t) \]
Note that land, etc. are NOT a factor of production
We will assume \(F(\cdot, \cdot)\) is constant returns to scale
\[ F(\alpha K, \alpha N) = \alpha F(K, N) \quad \forall \alpha > 0 \]
Assume \(F\) has diminishing marginal products
Define output per worker as \(y_t = Y_t/N_t\) and capital per worker as \(k_t = K_t/N_t\)
Take \(F\), divide by \(N_t\), use CRS, and define \(f(\cdot)\)
\[ \begin{aligned} Y_t &= z_t F(K_t, N_t)\\ \frac{Y_t}{N_t} &= \frac{z_t F(K_t, N_t)}{N_t}\\ y_t &= z_t F\left(\frac{K_t}{N_t}, \frac{N_t}{N_t}\right) = z_t F(k_t, 1) \equiv z_t f(k_t) \end{aligned} \]
\[ \begin{aligned} C_t + X_t &= Y_t \equiv \underbrace{z_t F(K_t, N_t)}_{\text{Total Output}}\\ \underbrace{K_{t+1}}_{\begin{smallmatrix} \text{Next} \\ \text{periods} \\ \text{capital} \end{smallmatrix}} &= \underbrace{(1-\delta)}_{\begin{smallmatrix}\text{depreciation} \\ \text{of capital} \end{smallmatrix}} K_t + \underbrace{X_t}_{\begin{smallmatrix}\text{investment} \\ \text{in new} \\ \text{capital} \end{smallmatrix}}, \delta \in (0,1) \end{aligned} \]
Consider production function of \(f(k) = k^{\alpha}\) for \(\alpha \in (0,1)\)
In this case, \(\alpha\) will be interpretable as the capital share of income
\[ \bar{k} = \left(\frac{s \bar{z}}{g_N + \delta}\right)^{\frac{1}{1-\alpha}} \]
g_N = 0.02
delta = 0.05
s = 0.2
z = 1.0
alpha = 0.5
k_ss = (s * z / (g_N + delta))^(1/(1-alpha))
k_values = 0.1:0.01:10.0
lhs = (g_N + delta) * k_values
rhs = s * z .* k_values.^alpha
plot(k_values, lhs, label=L"Growth-adjusted depreciation: $(\delta + g_N)k$",
xlabel=L"Capital per capita ($k$)")
plot!(k_values, rhs, label=L"Investment per capita: $s \bar{z} f(k)$")
vline!([k_ss], label=L"Steady State Capital: $\bar{k}$", linestyle=:dash)
Exogenous \(z_t\) sequence. e.g., \(z_{t+1}/z_t = 1 + g_z\) given some initial \(z_0\)
Population growth \(N_{t+1}/N_t = 1 + g_N\) given some initial \(N_0\)
\[ k_{t+1} = \frac{1}{1+g_N} \left[(1-\delta) k_t + s z_t f(k_t)\right],\quad \text{given } k_0 \]
Wages \(w_t = (1 - \alpha) z_t k_t^{\alpha}\) and rental rate of capital \(r_t = \alpha z_t k_t^{\alpha - 1}\)
Steady state capital \(\bar{k} = \left(\frac{s \bar{z}}{g_N + \delta}\right)^{\frac{1}{1-\alpha}}\) if \(g_z = 0\) and \(z_0 = \bar{z}\)
function plot45(f, xmin, xmax, x0, T; num_points = 100, label = L"h(k)",
xlabel = "k", size = (600, 500))
# Plot the function and the 45 degree line
x_grid = range(xmin, xmax, num_points)
plt = plot(x_grid, f.(x_grid); xlim = (xmin, xmax), ylim = (xmin, xmax),
linecolor = :black, lw = 2, label, size)
plot!(x_grid, x_grid; linecolor = :blue, lw = 2, label = nothing)
# Iterate map and add ticks
x = iterate_map(f, x0, T)
if !isnothing(xlabel) && T > 1
xticks!(x, [L"%$(xlabel)_{%$i}" for i in 0:T])
yticks!(x, [L"%$(xlabel)_{%$i}" for i in 0:T])
end
# Plot arrows and dashes
for i in 1:T
plot!([x[i], x[i]], [x[i], x[i + 1]], arrow = :closed, linecolor = :black,
alpha = 0.5, label = nothing)
plot!([x[i], x[i + 1]], [x[i + 1], x[i + 1]], arrow = :closed,
linecolor = :black, alpha = 0.5, label = nothing)
plot!([x[i + 1], x[i + 1]], [0, x[i + 1]], linestyle = :dash,
linecolor = :black, alpha = 0.5, label = nothing)
end
plot!([x[1], x[1]], [0, x[1]], linestyle = :dash, linecolor = :black,
alpha = 0.5, label = nothing)
end
plot45 (generic function with 1 method)
k_bar(p) = 1.7846741842265788
h(k_bar(p); p) = 1.7846741842265788
h(0.0; p) = 0.0
\[ \nabla h(k; p) = \frac{1}{1 + g_N} ( \alpha s z_t k^{1-\alpha} + 1 - \delta) \]
h_k(k; p) = (1 / (1 + p.g_N)) * (
p.alpha * p.s * p.z_bar * k^(p.alpha-1)
+ 1 - p.delta)
k_vals = range(0.0, 10.0; length=100)
plot(k_vals, h_k.(k_vals; p);
label = L"\nabla h(k)",
xlabel = "k",
title=L"Gradient of $h(k)$",
size=(600, 500), ylim=(0.0, 2.0))
vline!([k_bar(p)];label=L"h(\bar{k})=\bar{k}",
linestyle=:dash)
vline!([0.0];label=L"h(0)=0", linestyle=:dash)
hline!([1.0];linestyle=:dot, label=nothing,
alpha=0.5, lw=1)
function h_multi(k;s=0.95, delta=0.99)
return s*(-k^3/3 + k^2 + k/3) + (1 - delta)*k
end
k_min = 0.0
k_max = 2.2
k_vals = range(k_min, k_max; length=100)
plot(k_vals, h_multi.(k_vals);
label = L"h(k)",
xlabel = "k",
title="Multiple Crossings",
size=(600, 500))
plot!(k_vals, k_vals; label=nothing,
style=:dash)
h_multi_vec(k_vec) = [h_multi(k_vec[1])] # pack/unpack as vector
k_star_1 = fixedpoint(h_multi_vec, [0.0]).zero[1]
k_star_2 = fixedpoint(h_multi_vec, [1.0]).zero[1]
k_star_3 = fixedpoint(h_multi_vec, [2.0]).zero[1]
@show k_star_1, k_star_2, k_star_3;
(k_star_1, k_star_2, k_star_3) = (0.0, 1.1483123394919963, 1.8516876604860064)
h_multi_k(k;s=0.95, delta=0.99) = s*(-k^2 + 2 * k + 1/3) + (1 - delta)
@show k_star_1, h_multi_k(k_star_1)
@show k_star_2, h_multi_k(k_star_2)
@show k_star_3, h_multi_k(k_star_3);
(k_star_1, h_multi_k(k_star_1)) = (0.0, 0.32666666666666666)
(k_star_2, h_multi_k(k_star_2)) = (1.1483123394919963, 1.2557699441233567)
(k_star_3, h_multi_k(k_star_3)) = (1.8516876604860064, 0.5875633891937458)
Consumption per capital is \(c_t \equiv Y_t / N_t\)
Subsistence consumption per capita is \(c^*\)
Population growth rate for some \(\gamma \in (0,1)\)
\[ g_N(Y_t, N_t) \equiv \left(\frac{c_t}{c^*}\right)^{\gamma} - 1 \]
Note: \(c_t > c^* \implies g_N > 0\) and \(c_t < c^* \implies g_N < 0\)
Production is \(Y_t = z_t F(L, N_t)\) where \(L\) is land
Then following CRS logic, we see that consumption per capital is
\[ y_t = c_t = z_t f(\ell_t) = z_t \ell_t^{\alpha} \]
\[ \begin{aligned} \frac{N_{t+1}}{N_t} &= 1 + g_N(N_t) = \left(\frac{c_t}{c^*}\right)^{\gamma} \\ &= \left(\frac{z_t \ell_t^{\alpha}}{c^*}\right)^{\gamma} = \left(\frac{z_t}{c^*}\right)^{\gamma} \ell_t^{\alpha \gamma} \\ &= \left(\frac{z_t}{c^*}\right)^{\gamma} L^{\alpha \gamma} N_t^{- \alpha \gamma}\\ N_{t+1} &= \left(\frac{z_t}{c^*}\right)^{\gamma} L^{\alpha \gamma} N_t^{1 - \alpha \gamma} \end{aligned} \]
N_0 = N_bar(p) # old steady state
p = merge(p, (; z_bar = 2.0)) # changes a field
N_vals = iterate_map(N -> h(N; p), N_0, T)
c_vals = c.(N_vals; p)
plot(0:T, c_vals; label =[L"c_t" nothing],
title="Consumption-per-capita",
seriestype = [:scatter, :line],
xlabel = "t", size=(600, 400))
hline!([p.c_star];linestyle=:dash,
label=L"c^*", alpha=0.5)