Economist's doing dynamic programming and structural estimation

I love discourse because you get to learn from experts across fields. This is really nice!.

At the same time, I would like to learn from people with closely aligned work as mine. Thus, I was wondering whether some economists here who solve for value functions, policy functions, and undertake full solution structural model estimation in Julia could post links to their code. Ideally complete code for an article for instance, or that simply illustrates a single complete concept.

Thanks. This could also serve as a beginners guide for others too.

PS: I have googled around for this code, some of this is on my Github page. But it just seems to take forever to find this code. I have so have found only three/four academic articles.


You will find a lot to work with here: QuantEcon.jl – QuantEcon or here: especially if you want to work on macro questions.

1 Like

@jlperla has some code available for his papers, hopefully he doesn’t mind me sharing

There is also more work related to continuous time models here:


Don’t mind at all, but not entirely sure how useful it would me. My papers are all a little weird! Since “dynamic programming” and “structural estimation” are so brought, I think you need to narrow it down a bit. There are a buzzilion methods and models, with different approaches depending on what field you are working on, whether it is continuous or discrete time, etc.


Thanks everybody. @jlperla, I tend to read anything really to see what I can learn and incorporate into my own stuff. Now I am looking to introduce financial intermediation, financial frictions, and innnovation into my macro-climate models, and also structurally estimate models of electricity generation and wholesale power market clearing.

Other stuff I have found around the web that others may also find useful:

A paper by @aaowens using Julia that I came across: Does redistribution increase output? The centrality of labor supply | Athreya | Quantitative Economics

Another by @floswald GitHub - floswald/migration: Replication Kit for Oswald, Quantitative Economics (2019)

And another by @sglyon GitHub - sglyon/CLMMJuliaPythonMatlab: Codes to accompany the paper "Matlab, Python, Julia: What to Choose in Economics?" by Chase Coleman, Spencer Lyon, Lilia Maliar, and Serguei Maliar

1 Like

my stuff is legacy at this point (julia 0.6). on v0.6 it still runs though :slight_smile:

for climate model stuff, make sure to have @davidanthoff on your radar, eg. GitHub - fund-model/MimiFUND.jl: FUND - Climate Framework for Uncertainty, Negotiation and Distribution and a ton of other stuff.


Ben Moll has some code on his website for the HANK models (mostly Python but there were some Julia too)


Having a complete codebase for an article or working paper is useful for replication, but may not be ideal for learning. By the time of publication, code for structural empirical work usually contains a lot of accretion (changes to the model, semi-random requests by referees that enrich your appendix in the end, etc) that happened under time pressure and no one had the time or inclination for a clean refactoring (as usual, respect to those who do it anyway).

I usually find solving functional equations (HJB/Euler) the easiest part, and also the least computationally intensive. I use my own library, which is undergoing a refactoring right now (check back in a month or so, I am integrating Smolyak code that I used in a paper):

It is

  1. solving for general equilibrium objects, and
  2. dealing with distributions of heterogeneous agents

that I find tricky. (1) usually requires a good initial guess, homotopy methods, and gradual refinement of crude solutions. I find

useful for homotopy. Keeping the solution for policy functions automatically differentiable from the beginning (and unit testing for this) is very useful.

Dealing with distributions as states usually involves some ad hoc method that I construct based on the properties of the problem (ie I want a good approximation where the mass is). I usually try to get away with a rectangular grid, but when I can’t, I found


Generally, if you can keep your code automatically differentiable all the way up to a distance metric between simulated and actual data or a log posterior, it is a big win. But for complex models it requires some practice and refactoring.


SNM/examples/Auction at master · mcreel/SNM · GitHub has code for Tong Li’s auction model from the paper Indirect inference in structural econometric models - ScienceDirect


I know of (but never used) Dolo.jl by @albop (, albop (Pablo Winant) · GitHub) which implements value iteration for economics. I once took his multilinear interpolation routine for my own dynamic programming Python package (because dolo was at first a Python package).


I have quite a lot of code for discrete choice dynamic programming ala Rust (the code for Solving dynamic discrete choice models using smoothing and sieve methods - ScienceDirect is only for solving for the value function and is not public but I could clean it up…), but it doesn’t appear to be what you’re after.


@pkofod. I am certain the code would be very helpful. For instance when modelling powerplant operations in my case. The code could also be helpful in other ways and to other people. So you if you have time please clean it up and post.