Portrait of Jeffrey E. Sun

Jeffrey E. Sun

I am an Assistant Professor of Economics at the University of Toronto.

I am interested in combining climate science and structural economic modeling to study climate impacts in equilibrium. I also develop computational tools for solving rich heterogeneous-agent models.

You can find my CV here.

Email: je.sun@utoronto.ca


Working Papers


Work in Progress


Solving Heterogeneous-Agent Models

My work on solving heterogeneous-agent models essentially boils down to decomposing large classes of models into:

  1. A household block.
  2. A DAG of simultaneous equations representing within-period equilibrium.
  3. An outer loop representing dynamic equilibrium, including steady state, perfect-foresight transition, and the global solution with aggregate shocks.

I then have computational work on solving each of these components separately (and compatibly).

For Component 1 (the household block), I show that the household blocks of many models we care about can be built by formally concatenating a small number of primitive “stages”. I have a Julia package, HouseholdStages.jl, which implements these stages with platform-agnostic (CPU or GPU), differentiable code, with many examples of how complex household blocks can be built out of them. Examples include models with space, sector switching, consumption-savings, income heterogeneity, wealth heterogeneity, multiple assets, directed search, entry and exit, rational inattention, marriage markets, endogenous human capital accumulation, endogenous labour supply, unemployment, and overlapping generations.

For Component 2 (the DAG), I have some notes (not necessarily novel work or enough for a paper) on using automatic differentiation together with analytical implicit derivatives to efficiently solve optimal policy problems or solve models with granular agents.

For Component 3 (the outer loop) I have some work developing Neural Value Function Iteration (nVFI), showing how discrete-time heterogeneous-agent models with aggregate shocks can be globally solved by using neural networks sparingly, only to approximate the continuation value function.

I also have a set of class notes which introduces these ideas together over the course of eight lectures. (With interactive Julia notebooks!)

One of the reasons it can be useful to aggressively decompose household blocks into stages, as I advocate, is that individual stages can be optimized by computational researchers, then used off the shelf by practitioners. This dropdown contains some examples of such optimizations, which are part of what makes HouseholdStages.jl so fast.

Speedup factor: log n (n = #(gridpoints), relative to individual lookups)

When solving value functions using backwards induction or simulating distributions forward, if the gridpoints are defined in terms of endogenous quantities (e.g. wealth), you often have to reinterpolate the function or distribution back onto the grid. Existing interpolation libraries look up each gridpoint independently. With n gridpoints, each query is O(log n) and the whole reinterpolation is O(n log n). But if the grid is monotonic, you only need to iterate over each grid once, which you can do in O(n) time.

Reinterpolating is slightly different for functions and distributions, since distribution approximations depend on the density of gridpoints.

Speedup factor: up to n0.62 or so, with big improvement on constant (if n = #(locations), relative to naive approach)

With n locations and m possible within-location agent states, if agents receive Gumbel-distributed location preferences, then to solve for the value function and choice probabilities, you have to solve for n*n*m possible agent-choice pairs. Luckily, this can be constructed as a single matrix multiplication, which can even be done non-allocatingly if set up properly. Highly-optimized linear algebra libraries can then be used.

Speedup factor: n (n = #(gridpoints), relative to naive individual lookups. Speedup factor log n over optimized individual lookups)

In many models, agents must make consumption savings decisions. Assuming a discretized wealth grid, the most flexible solution is to maximize over all possible continuation values for each agent, but this requires O(n2) total computations. If both continuation value and optimal saving are increasing in wealth, each agent needs only consider possible choices that lie between the choices of adjacent agents. By using binary search for individual lookups and a form of modified binary search to constrain the search space for individual agents, we can compute the optimal decisions of n agents who differ only by wealth using only 2n computations.


Notes for Students


Editorial


From a Previous Life

Mathematics Publications

  • Bora, S., Damelin, S., Kaiser, D., & Sun, J. (2023). An algebraic-coding equivalence to the maximum distance separable conjecture. Involve, a Journal of Mathematics, Forthcoming.
  • Güntürkün, S., Jeffries, J., & Sun, J. (2020). Polarization of neural rings. Journal of Algebra and Its Applications, 19(08), 2050146.
  • Hua, M., Damelin, S. B., Sun, J., & Yu, M. (2017). The truncated and supplemented Pascal matrix and applications. Involve, a Journal of Mathematics, 11(2), 243–251.