File:Phase diagram of the Ramsey model.svg

From testwiki
Jump to navigation Jump to search
    Original file (SVG file, nominally 1,313 × 1,875 pixels, file size: 2.14 MB)

    This file is from Wikimedia Commons and may be used by other projects. The description on its file description page there is shown below.

    Summary

    Description
    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

    1. n = population growth rate
    2. δ = capital depreciation rate
    3. ρ = utility discounting rate

    n, δ, ρ = 1, 1, 0.5

    1. σ = "elasticity of intertemporal substitution in consumption",
    2. which is a constant 1 if u(c) = ln c.

    σ = 1

    1. production function

    f(k) = √k df(k) = 1/(2√k) invdf(y) = 1/(4 * y^2)

    1. dynamics of (k, c)

    dotkc(k, c) = [f(k)-c-(n + δ)k

                  (df(k)-(δ + ρ)) * σ * c]
    
    1. dotkc(x, y) = [-y - x^3; x^5]
    1. the ̇c = 0 curve

    dotc0(c) = invdf(δ + ρ)

    1. 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

    1. 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)

    1. 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)

    1. 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)

    1. display plot

    scene

    1. save("Ramsey.svg", scene)
    ```
    Date
    Source Own work
    Author Cosmia Nebula

    Licensing

    I, the copyright holder of this work, hereby publish it under the following license:
    w:en:Creative Commons
    attribution share alike
    This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
    You are free:
    • to share – to copy, distribute and transmit the work
    • to remix – to adapt the work
    Under the following conditions:
    • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
    • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

    Captions

    phase diagram of the Ramsey model

    Items portrayed in this file

    depicts

    7 January 2023

    File history

    Click on a date/time to view the file as it appeared at that time.

    Date/TimeThumbnailDimensionsUserComment
    current16:12, 8 January 2023Thumbnail for version as of 16:12, 8 January 20231,313 × 1,875 (2.14 MB)wikimediacommons>Cosmia Nebulafix caption

    There are no pages that use this file.