Quantitative Macroeconomics with AI and Machine Learning

Zhigang Feng  ·  Professor of Economics

E-mail: z.feng2@gmail.com

Webpage: https://sites.google.com/site/zfeng202/

Course Ecosystem

Twelve topics, organized by subject rather than by calendar date, so this works as a taught course or as self-study. Every topic has a deck; most have a lab; and most were taught on camera — see the recordings. The written counterpart is the textbook 机器学习与数量宏观经济学.

The AI frontier — language models as measurement, retrieval, and agentic research pipelines — is the sister course, AI for Economic Research: Dynamic Models, Language, and Agents. Together:

Classical Methods ML & Deep Learning Agentic AI Research

This site is the first two stages.

Course Description

This course prepares economists for a change in what the job requires. As AI takes over more of the code, the economist's advantage moves to critical validation and economic safeguarding — designing algorithms, directing tools deliberately, and auditing what comes back for both technical correctness and economic sense. The name for that role in this course is the Research Architect.

You will work through the computational and statistical tools for analyzing structural economic models, with the traditional methods (dynamic programming, perturbation, projection) and the modern ones (deep learning, reinforcement learning) treated as one toolkit rather than two camps. Python and PyTorch are the implementation languages throughout, and high-performance computing gets its own topic.

The bottleneck has moved

It is no longer writing code. It is knowing what code to write, how to establish that it works, and whether the results mean anything economically. Your advantage is not syntax. It is translating economic problems into precise algorithmic specifications, recognizing when numerical output violates economic principles, auditing generated code for the subtle bugs that quietly corrupt an economic conclusion, and using AI as a complement that amplifies you rather than a substitute that replaces you.

What You Will Build: Four Integrated Competencies

1 · Theoretical & Algorithmic Mastery

Master the economic theory and the numerical method on paper, before touching code — the core models, and both conventional computation (VFI, perturbation, projection) and ML/RL-based approaches. This logic is human-driven and tool-agnostic. It is the part that cannot be outsourced, and the foundation everything else rests on.

2 · Technical Fluency & Tool Literacy

The goal is not to become an expert programmer. It is to understand the computational landscape well enough to direct tools effectively and evaluate what they return.

3 · AI-Augmented Implementation

Collaborate with AI coding assistants through specification-driven development: turn the algorithmic logic from Competency 1 into a specification detailed enough — pseudocode, data structures, objectives, validation criteria — that a tool can produce working code from it while you stay the architect. This is the fastest-moving competency in the course; the landscape shifts every few months and the material shifts with it.

4 · Critical Validation & Economic Safeguarding

This is the heart of the course. It determines whether you control the tools or the tools control you.

Learning Objectives

By the end you should be able to:

This curriculum has been developed and refined since 2019 through teaching at Zhongnan University of Economics and Law (2021–2024), the University of International Business and Economics (2023–2025), Huazhong University of Science and Technology (2019), Iowa State University (2025), the University of Miami (2025–2026), and Wuhan University (2024–2025).

Hands-On Philosophy

The hands-on sessions are the core of the course, not an appendix to it. Each one follows the same five-step workflow, which is the Research Architect role made into a procedure:

The specification-driven loop

  1. Mathematical & economic formulation. Start on paper: the optimization problem, the recursive formulation, the constraints.
  2. Algorithmic specification. Design the algorithm and write the pseudocode. This is the human logic that cannot be delegated.
  3. Define deliverables. State the outputs explicitly — a policy function plot, a graph of Euler equation errors, a table of simulated moments.
  4. AI-augmented implementation. Hand the specification to an assistant and get the first Python/PyTorch implementation.
  5. Critical validation & expansion. The crucial step. Audit for bugs, economic plausibility and numerical stability; then refine, extend, and loop.

This is not a set of static pre-AI notebooks. The implementation is live, customizable and expandable, and you are in an interactive loop with the tool — using it to fill gaps ("explain this PyTorch function") while you safeguard the output with economic and computational judgment.

The sessions are designed to prove a specific point: your background understanding matters. Several deliberately start from a vague prompt that yields a flawed or naive answer, so you can see what detailed, economically-informed instruction and rigorous validation actually buy you.

Topics

Subject to change as the field moves and depending on class interest. Each topic below links to its deck, its lab, and its recording where one exists.

On this page

Topic 1 — Artificial Intelligence for Economics Research

Deck: 92 slides  ·  Lab 1  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Generic versus specification-driven prompting Lab 1

Objective. Demonstrate concretely how a precise, specification-driven prompt outperforms a generic request.

Activities. Solve the classical optimal growth model (which has a closed-form solution, so correctness is checkable); estimate an AR(1) process for TFP shocks; then compare the generic and specification-driven outputs for correctness and economic plausibility, and discuss why they differ.

Topic 2 — Introduction to Computation for Macroeconomists

Deck: 45 slides  ·  Lab 2A  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Setting up, and first steps Lab 2A

Objective. Get a working Python environment, then apply the Research Architect workflow to simulate the Solow growth model.

Activities. Install Python (Anaconda) and VS Code; see why 0.1 + 0.2 ≠ 0.3 and what that implies for convergence tests; translate the Solow model into pseudocode and then into Python loops; move from loops to vectorized NumPy.

Topic 3 — Programming Basics for Economists

Deck: 90 slides  ·  Lab 3  ·  ▶ Recording (2025 series)

Conceptual content

🛠️ Hands-on: Object-oriented economics & PyTorch basics Lab 3

Objective. Solve a two-period consumption-saving problem, bridging standard economic modelling (SciPy) and modern AI frameworks (PyTorch tensors).

Outcome. Organize economic models with Python classes, perform numerical optimization for intertemporal choice, and run basic linear algebra in both NumPy and PyTorch with a feel for the performance difference.

Activities. Build an Agent class encapsulating parameters (β, r) and utility; solve with scipy.optimize; visualize how optimal consumption responds to the interest rate; create tensors and see the CPU/GPU distinction; benchmark matrix operations across pure Python, NumPy and PyTorch.

Topic 3A — AI Coding for Dynamic Equilibrium Models

Deck: 83 slides  ·  Starter project  ·  ▶ Recording

A standalone session that formalizes the Research Architect workflow for AI-assisted macro coding. The organizing idea is to separate algorithm design from code implementation: the economist defines theory, numerical method and validation criteria; the tool handles implementation loops under supervision.

Conceptual content

🛠️ Hands-on: An AI coding workflow for macro models Starter project

Objective. Implement and validate a dynamic equilibrium model with a structured, specification-first workflow.

Outcome. Convert an economic specification into a reproducible pipeline, enforce validation gates, and organize project memory with skills, agents and rules.

Activities. Start from the provided template; implement a baseline version with explicit convergence and Euler-error diagnostics; add one extension at a time, validating each before moving on; run specialized review checks for numerical stability and economic consistency.

Topic 4 — Numerical Methods for Macroeconomists

Deck: 78 slides  ·  Lab 4  ·  ▶ Recording 1, 2

Conceptual content

🛠️ Hands-on: Numerical methods & version control Lab 4

Objective. Implement the core numerical algorithms and manage the research code lifecycle with Git and GitHub.

Outcome. Initialize a repository for your research, select and implement appropriate SciPy solvers for equilibrium and optimization problems, and discretize stochastic processes for dynamic models.

Activities. Set up a repository, write a .gitignore, make the first commit/push; solve for market-clearing prices in a non-linear supply/demand system with Newton-Raphson; solve a constrained utility maximization and validate the first-order conditions; approximate a production function with linear versus cubic splines; discretize an AR(1) productivity shock with Tauchen and check the moments against simulation.

Topic 5 — Introduction to Machine Learning for Economists

Deck: 98 slides  ·  Labs 5A, 5B  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Fitting data with neural networks, and using APIs Labs 5A, 5B

Objective. Build a network from scratch in PyTorch to fit synthetic policy functions and then real economic data, including fetching it from an online API.

Outcome. Construct a feedforward network with torch.nn.Module, write a training loop with backpropagation, manage train/test splits, and interpret predictions in economic terms.

Activities. Train a network to learn a known non-linear consumption function; write the training loop by hand (forward pass, loss, backpropagation, optimizer step); pull unemployment and inflation from FRED with pandas_datareader; fit a Phillips curve and visualize the learned relationship; use learning curves to diagnose overfitting.

Topic 6 — Solving Macroeconomic Models Using Machine Learning

Deck: 67 slides  ·  Labs 6A, 6B  ·  ▶ Recording 1, 2

Conceptual content

🛠️ Hands-on: The bridge — from VFI to deep learning Labs 6A, 6B

Objective. Solve the stochastic optimal growth model first with classical grid-based VFI to establish a benchmark, then reframe it as supervised learning and solve it with neural networks.

Outcome. Understand where grid-based methods run out (the curse of dimensionality) and how networks get around it, by implementing an actor-critic architecture where one network approximates the value function and another the policy.

Activities. Lab 6A — classical VFI with discretization, producing the reference solution. Lab 6B — build a ValueNet and a PolicyNet in PyTorch; implement alternating updates (minimizing Bellman error against maximizing expected utility); then overlay the network solution on the VFI solution and quantify the gap.

Topic 7 — Numerical Solution Methods for Dynamic Models

Deck: 58 slides  ·  Lab 7  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Solving the RBC model with VFI and time iteration Lab 7

Objective. Implement the foundational numerical methods for the stochastic growth model, by grid-based dynamic programming and by Euler equation methods.

Outcome. Calibrate the RBC model, construct appropriate grids, implement VFI with various interpolation schemes, implement time iteration, and compare the two on implementation complexity and performance.

Activities. Calibrate to US business-cycle moments; build capital grids and discretize productivity shocks; implement VFI with linear and cubic spline interpolation; implement time iteration on the consumption Euler equation; monitor convergence and visualize policy functions; simulate and compute business-cycle statistics.

Topic 8 — Advanced Numerical Methods and Accuracy Assessment

Deck: 61 slides  ·  Lab 8  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Accelerated solutions and accuracy assessment Lab 8

Objective. Implement acceleration techniques and EGM, and build the habit of rigorously checking whether a numerical solution is actually right.

Outcome. Implement Howard's improvement and EGM, compute Euler equation errors across the state space, run systematic accuracy comparisons, and choose methods based on the problem rather than on habit.

Activities. Implement Howard's policy improvement and measure the speedup; exploit monotonicity via binary search; implement EGM for the RBC model; compute and visualize Euler equation errors; run sensitivity analysis over grid density, tolerance and interpolation method; generate impulse responses and check them for economic plausibility.

Topic 9 — Perturbation and Projection Methods

Deck: 133 slides  ·  Lab in preparation  ·  ▶ Recording

Conceptual content

🛠️ Hands-on: Perturbation and Chebyshev approximation for the RBC model

Objective. Implement first- and second-order perturbation and Chebyshev projection for the RBC model, and compare local against global accuracy in different regions of the state space.

Activities. Compute the deterministic steady state; derive and implement the first-order log-linear approximation; check Blanchard-Kahn conditions; implement second-order perturbation with pruning; generate impulse responses; implement Chebyshev approximation of the policy functions, choosing collocation nodes and solving for the coefficients; then compare perturbation, Chebyshev and VFI on accuracy across the state space — near the steady state and far from it — and on solution time and memory.

The notebook for this session is still being written; the recording works through the material in the meantime.

Topic 10 — High-Performance and Parallel Computing

Deck: 33 slides  ·  Lab in preparation

Conceptual content

🛠️ Hands-on: Parallelizing the RBC VFI solver

Objective. Parallelize the VFI solver both the traditional way (MPI) and the modern way (PyTorch DDP), and compare how each scales.

Activities. Analyze the VFI algorithm for parallelization opportunities; partition the state space across processes; write mpi4py code distributing grid points to workers with gather/scatter for value function updates; handle communication overhead and synchronization; parallelize neural VFI with DDP; write SLURM scripts for CPU and GPU jobs; run a scaling study and measure speedup against cores/GPUs; see Amdahl's law bite in practice; profile to separate computation from communication cost.

Notebook in preparation. The deck's mpi4py and SLURM snippets are runnable as they stand.

Topic 11 — Heterogeneous Agents Models with Machine Learning

Deck: 122 slides  ·  Lab 11A  ·  ▶ Recording, Aiyagari bridge, 2025 I, II

Conceptual content

🛠️ Hands-on: Solving Aiyagari and Krusell-Smith Lab 11A

Objective. Implement and compare stationary and global solution methods for heterogeneous-agent models, from canonical Aiyagari to Krusell-Smith with aggregate shocks.

Outcome. Compute stationary equilibria, diagnose distributional dynamics, train DeepHAM-style value/policy approximations, and implement Euler-based DEQN training.

Activities. Build the canonical Aiyagari loop (policy solution, stationary distribution, market-clearing rate); check the uniqueness and convergence assumptions and the solver's numerical robustness; extend to Krusell-Smith, treating the distribution (or its moments) as an evolving state; train DeepHAM and track learning stability; train DEQN by minimizing Euler residuals across many parallel economies; compare the two on accuracy, speed and scalability.

Topic 12 — Heterogeneous-Agent OLG Models

Deck: 73 slides  ·  Lab 12

Conceptual content

🛠️ Hands-on: Stationary and dynamic OLG models Lab 12

Objective. Solve a stationary OLG model with idiosyncratic risk by traditional methods, then extend it with ML to include aggregate uncertainty, bonds and government policy.

Outcome. Implement backward induction for lifecycle problems, compute stationary distributions across age and wealth, solve for general equilibrium prices, implement networks with embedded market clearing, and apply homotopy methods for training stability.

Activities. Set up demographics, lifecycle income and retirement; implement backward induction from terminal age; build the transition matrix across ages with survival probabilities; forward-iterate to the stationary distribution over (age, wealth, productivity); clear markets by iterating on the interest rate and wage; analyze lifecycle consumption, saving and wealth accumulation. Then add aggregate shocks; design an age-conditioned architecture; implement the market clearing layer; write the custom loss weighting Euler and market-clearing errors; use Fisher-Burmeister for complementarity; implement homotopy training from a simpler model upward; pre-train on fixed prices before going endogenous; validate the ML solution against the traditional one in the stationary case; and simulate transition dynamics after an aggregate shock.

Supplementary Resources

Recordings — the whole course on video

Every topic here except 3, 10 and 12 was taught on camera in the 2026 University of Miami offering: nine lectures, about nine and a half hours, free and without registration. Four earlier series going back to 2024 cover the same ground more slowly, and the 2025 Miami series is the best treatment of Topic 3.

All recordings, mapped topic by topic  ·  2026 series on Bilibili

Textbook

机器学习与数量宏观经济学 (Machine Learning and Quantitative Macroeconomics) by Zhigang Feng bridges classical numerical methods and modern deep learning for dynamic economic models. It is the primary written reference for this course.

The sister course — the AI frontier

AI for Economic Research: Dynamic Models, Language, and Agents continues where Topic 12 stops: reinforcement learning in depth, language models as economic measurement, retrieval-augmented generation, and running a research pipeline with agentic AI. Four topics that used to close this syllabus now live there — see retired topics.

References

Acknowledgments

I gratefully acknowledge insightful discussions with the colleagues below, and the teaching experiences at the institutions that follow.

Huazhong University of Science and Technology · Iowa State University · University of International Business and Economics · University of Miami · Wuhan University · Xiamen University · Zhongnan University of Economics and Law