English: Model based on Advanced Macroeconomics: An Easy Guide (Campante et al 2021), chapter 3.
Notation: k = capital (stock) per capita c = consumption (flow) per capita n = population growth rate δ = capital depreciation rate ρ = utility discounting rate
We have the dynamics in $(k, c)$ space: $$\begin{cases} \dot k = f(k) - c - (n+\delta)k\\ \dot c= (f'(k) - (\delta + \rho))\sigma c \end{cases}$$ with initial conditions $$k(0) = k(0), \quad c(0) = u'^{-1}(\lambda(0))$$ and transversality condition $$\lim_t (ku'(c) e^{(n-\rho) t} )= 0$$
Here, $\sigma$ is the "elasticity of intertemporal substitution in consumption". $$\sigma(c) := - \frac {u'(c)}{u(c)c} > 0$$ In particular, if we let $u(c) = \ln c$, then $\sigma(c) = 1$, a constant.
Now plot the diagram with Julia:
```julia using CairoMakie, LinearAlgebra
- n = population growth rate
- δ = capital depreciation rate
- ρ = utility discounting rate
n, δ, ρ = 1, 1, 0.5
- σ = "elasticity of intertemporal substitution in consumption",
- which is a constant 1 if u(c) = ln c.
σ = 1
- production function
f(k) = √k df(k) = 1/(2√k) invdf(y) = 1/(4 * y^2)
- dynamics of (k, c)
dotkc(k, c) = [f(k)-c-(n + δ)k
(df(k)-(δ + ρ)) * σ * c]
- dotkc(x, y) = [-y - x^3; x^5]
- the ̇c = 0 curve
dotc0(c) = invdf(δ + ρ)
- the ̇k = 0 curve
dotk0(k) = f(k) - (n + δ) * k
using Roots invdotk0 = find_zero(dotk0, (0.1, 0.3), Roots.A42()); function plotRamsey(x, y)
xs = repeat(x, outer=length(y)) ys = repeat(y, inner=length(x)) xlims!(minimum(x), maximum(x)) ylims!(minimum(y), maximum(y))
# the ̇c=0 curve lines!(dotc0.(y), y, color=:black) # the ̇k=0 curve lines!(x, dotk0.(x), color=:blue)
# the equilibrium point scatter!([dotc0(0)],[dotk0(dotc0(0))], color=:black) scatter!([invdotk0],[0], color=:red)
# the flow vector field vectors = dotkc.(xs, ys) norms = vec(norm.(vectors)) scaled_norms = tanh.(norms)/10
us = map((x) -> x[1], vectors) vs = map((x) -> x[2], vectors) us ./= norms vs ./= norms us .*= scaled_norms vs .*= scaled_norms
arrows!(xs, ys, us, vs, arrowsize = 6, linecolor=scaled_norms, arrowcolor = :black)
end
- define Figure
width, height = 1400, 2000 scene = Figure(resolution = (width, height)) fsize = 30
Axis(scene[1:2,1:2], backgroundcolor = "white",
xlabel = L"$k$", xlabelsize=fsize, ylabel = L"$c$", ylabelsize=fsize, title = L"Ramsey model with $f(k) = \sqrt{k}$, and $n, δ, ρ, σ = %$(n, δ, ρ, σ)$", titlesize=fsize)
xmin, xmax, xres = 0.0001, 0.3, 51 ymin, ymax, yres = -0.02, 0.15, 51
x = range(start = xmin, stop = xmax, length = xres) y = range(start = ymin, stop = ymax, length = yres)
plotRamsey(x, y)
- Closeup around the interior equilibrium
Axis(scene[3,1], backgroundcolor = "white",
xlabel = L"$k$", xlabelsize=fsize, ylabel = L"$c$", ylabelsize=fsize, title = L"interior equilibrium at $k, c = %$(round(dotc0(0), sigdigits=2)), %$(round(dotk0(dotc0(0)), sigdigits=2))$", titlesize=fsize)
ϵ = 0.01 xmin, xmax, xres = dotc0(0)-ϵ, dotc0(0)+ϵ, 31 ymin, ymax, yres = dotk0(dotc0(0))-ϵ, dotk0(dotc0(0))+ϵ, 31 scatter!([dotc0(0)],[dotk0(dotc0(0))], color=:black)
x = range(start = xmin, stop = xmax, length = xres) y = range(start = ymin, stop = ymax, length = yres)
plotRamsey(x, y)
- Closeup around all-saving equilibrium
Axis(scene[3,2], backgroundcolor = "white",
xlabel = L"$k$", xlabelsize=fsize, ylabel = L"$c$", ylabelsize=fsize, title = L"all-saving equilibrium at $k = %$(round(invdotk0, sigdigits=2))$", titlesize=fsize)
ϵ = 0.01 xmin, xmax, xres = invdotk0-ϵ, invdotk0+ϵ, 31 ymin, ymax, yres = -ϵ, +ϵ, 31
x = range(start = xmin, stop = xmax, length = xres) y = range(start = ymin, stop = ymax, length = yres)
plotRamsey(x, y)
- display plot
scene
- save("Ramsey.svg", scene)
```