# Setup
import numpy as np
import matplotlib.pyplot as plt
import torch
import torch.nn as nn
torch.manual_seed(42)
np.random.seed(42)
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(f"PyTorch {torch.__version__} on {device}")Week 10: Frontiers and Course Synthesis
Deep Learning for Macroeconomics — Honours, The University of Edinburgh
Instructor: Juan Zurita · juan.zurita@ed.ac.uk
Learning objectives
By the end of this notebook you will be able to:
- Describe sequence-space methods and how they relate to DEQNs
- Understand the basics of continuous-time heterogeneous-agent models
- Choose the right computational method for a given economic model
- Identify open research questions at the frontier of computational macro
1. Sequence-space methods
An alternative to recursive methods: solve for the entire sequence of equilibrium objects \(\{c_t, k_t\}_{t=0}^T\) simultaneously.
Auclert et al. (2021) showed that many HA models can be solved efficiently in sequence space using Jacobians — and neural networks can represent these Jacobians.
DEQNs in sequence space
Instead of parameterising \(c(k, z; \theta)\) recursively, parameterise the history-dependent policy: \[c_t = \text{NN}(k_0, z_0, z_1, \ldots, z_t; \theta)\]
This is what Scheidegger calls Sequence-Space DEQNs (Lecture 10).
2. Continuous-time heterogeneous agents
The HJB-KFE system for continuous-time HA models:
\[\rho V(a, z) = \max_c \big\{ u(c) + V_a(a,z) [ra + wz - c] \big\} + \text{(shock transition terms)}\]
\[0 = -\frac{\partial}{\partial a}[s(a,z) g(a,z)] + \text{(shock transition terms)}\]
where \(g(a,z)\) is the stationary distribution. PINNs solve both equations simultaneously — a powerful approach pioneered by Fernández-Villaverde, Hurtado & Nuño (2023).
3. Decision guide: which method when?
START
│
├─ Dimensions ≤ 3? ──── YES ──→ VFI or projection (PNM methods)
│ Fast, well-understood, guaranteed convergence
│
├─ Continuous time? ──── YES ──→ PINNs (Week 7)
│ Natural for HJB/KFE systems
│
├─ Occasionally binding constraints? ── YES ──→ DEQNs + Fischer-Burmeister (Week 6)
│ Handles kinks naturally
│
├─ Heterogeneous agents? ── YES ──→ DEQNs + Young's method (Week 8)
│ Scales beyond Krusell-Smith moments
│
├─ Need estimation? ── YES ──→ Surrogates + SMM (Week 9)
│ Fast gradient-based optimisation
│
└─ High-dimensional (10+ states)? ── YES ──→ DEQNs (Weeks 4-5)
Only feasible approach
4. Open questions and research frontiers
Convergence guarantees for DEQNs — gradient descent can get stuck in local minima. When can we guarantee global convergence?
Transfer learning across models — can a network trained on one calibration be fine-tuned for another? (Huge speed-up for estimation)
Real-time model solving — can we solve DSGE models fast enough for nowcasting and real-time policy analysis?
Interpretability — can we extract economic insights from trained networks? (Feature importance, attention maps)
Multi-agent deep learning — can we solve game-theoretic models (multiple interacting agents) with neural networks?
5. Course synthesis
| Week | Topic | Key method | Key model |
|---|---|---|---|
| 1 | Neural networks as approximators | MLP, PyTorch | Brock–Mirman (supervised) |
| 2 | Deep learning fundamentals | Backprop, Adam | Function approximation |
| 3 | Automatic differentiation | Autograd | Economic derivatives |
| 4 | DEQNs I | Euler residual loss | Deterministic growth |
| 5 | DEQNs II | Quadrature for expectations | Stochastic RBC |
| 6 | Constraints | Fischer–Burmeister | Consumption–savings |
| 7 | PINNs | PDE residual loss | Cake-eating HJB |
| 8 | Heterogeneous agents | Young’s method + DEQN | Aiyagari / Krusell–Smith |
| 9 | Surrogates & estimation | GP, SMM | DICE climate model |
| 10 | Frontiers | Sequence-space, continuous-time HA | Research directions |
The unifying idea
Every method in this course follows the same pattern:
- Parameterise the unknown function (policy, value, distribution) as a neural network
- Define a loss from the model’s own equations (Euler, HJB, complementarity, PDE residual)
- Minimise the loss using gradient descent + automatic differentiation
- Verify using Euler-equation errors, simulation, or comparison to known solutions
Final exercise: choose your own model
Pick a dynamic economic model from your macroeconomics courses (or from research papers) and:
- Write down the equilibrium conditions
- Identify which method from this course is most appropriate
- Implement a DEQN (or PINN) solution
- Verify your solution and compute Euler-equation errors
This could be the start of a dissertation chapter or an Honours thesis project.
Course references
- Azinovic, M., Gaegauf, L., & Scheidegger, S. (2022). “Deep Equilibrium Nets.” International Economic Review, 63(4).
- Scheidegger, S. (2025). Deep Learning for Solving and Estimating Dynamic Economic Models.
- Fernández-Villaverde, J., Hurtado, S., & Nuño, G. (2023). “Financial Frictions and the Wealth Distribution.” Econometrica, 91(4).
- Auclert, A., Bardóczy, B., Rognlie, M., & Straub, L. (2021). “Using the Sequence-Space Jacobian to Solve and Estimate Heterogeneous-Agent Models.” Econometrica, 89(5).
- Nordhaus, W. (2017). “Revisiting the Social Cost of Carbon.” PNAS, 114(7).
Thank you for taking this course. Good luck with your research!