This package models the basic Aiyagari (1994) model of heterogeneous agents in discrete time. This classic model for examining inequality and wealth distribution considers a world with incomplete markets, where economic agents are credit-constrained and therefore cannot perfectly insure themselves against idiosyncratic income shocks.
This is basically a homework toy model made into a package. I made this for fun and thus don't plan to register this package to General. Nevertheless, this package can be installed by running the following command in a Julia REPL:
using Pkg; Pkg.add(url="https://github.com/hieutkt/Aiyagari.jl.git")
For now, basic interactions are as follow:
using Aiyagari
model = AiyagariDiscrete(n=1000) #Tweak around with the model inputs
sol = solve(model)
plot_results(sol, model, "results.png")
I have some ideas to improve this package. I probably won't get around to do them all (as the fall semester is starting) but here they are:
- Streamline interface to conform with idiomatic Julia:
- Proper
display()
properties for models objects - Create abstract
EconomicsModel
andModelSolution
types - Solve models by running
solve()
which takes a model and returns a solution
- Proper
- Module managements
-
Pkg
supports supports multi-package repositories. It might be useful to have one large repository that contains the core functions that is being used in most modelling workflows, and then having specific components e.g.AiyagariDiscrete()
be sub-modules that one only loads when needed. I like the idea of having a modular system of economics computational tools. Need to think more about this but look for big projects like Makie.jl or FasiAI.jl to see how they implement it. - In such case, we can lazily pre-compile costly components of the package (For example, plotting with
CairoMakie.jl
, optimizations withJuMP.jl
). Require.jl seems to be suitable for this purpose, but I'm not sure if it is needed.
-
- Graphing capabilities
- Drawing graphs with a dwim
plot()
function which takes a model solution and return a plot object - Write atomic plotting functions that do only one thing and do it well. Make them composable like with the rest of the Makie.jl ecosystem
- Drawing graphs with a dwim
- Some supporting functionalities
- Discretization using Tauchen’s method.
- Markov matrices and operations. Computation of invariant distributions is already there but is in rough stages. Might as well importing from some library if implement it well.
- Improve performance for VFI:
- Caching the utility matrix: The first term in the Bellman equation is independent of the value function
$v_t$ , so we should compute them only once! Benchmark improved from2.566 s ± 3.405 ms
to2.002 s ± 39.059 ms
. - After some more optimizations this implementation now solve the simpliest models (3 income states, 500 wealth grid) to
858.676 ms ± 22.632 ms
. - Only compute the optimal policy for the last iteration:
506.230 ms ± 42.657 ms
- Caching the utility matrix: The first term in the Bellman equation is independent of the value function
- Documentations:
- Write docs for everything
- A documentation site with Documenter.jl, but only if it is easy enough. This is only a small package after all
- Miscellaneous
- Fancy progress indicator: using Term.jl, OnlineStats.jl or ProgressMeter.jl