Lab Notebooks

Twelve Jupyter notebooks plus a Claude Code starter project. Every one is CPU-only and runs offline once its data is bundled — no GPU, no API key, no paid service. Run them in the cloud with a single click, or locally if you prefer your own machine.

▶  Open in GitHub Codespaces Browse the repository

Option 1 — run in the cloud (Codespaces)

Quota. Any GitHub account can launch a codespace on this repository, and it runs on your own free monthly allowance (120 core-hours + 15 GB storage on a personal account) — nobody else is billed for your session. Stop idle codespaces and the free tier comfortably covers the whole course.

Option 2 — run locally

Python 3.11 or newer, then:

git clone https://github.com/vonzhg/Quant_Macro.git
cd Quant_Macro
python -m venv .venv && source .venv/bin/activate   # Windows: .venv\Scripts\activate
pip install -r requirements.txt
jupyter lab

requirements.txt pins the CPU build of PyTorch, so the install stays small. The repository also carries the full LaTeX sources under source/, so the clone is around 150 MB — add --filter=blob:none if you only want the notebooks.

Notebooks

Each lab is paired with a topic in the syllabus; the hands-on session described there is what the notebook implements.

Topic 1 — Generic vs. Specification-Driven Prompting
The optimal growth model with a closed-form solution to validate against, and an AR(1) TFP estimate — the same two problems asked of AI two ways.
Download
Topic 2 — Introduction to Computation
Environment setup, floating point (why 0.1 + 0.2 ≠ 0.3), the Solow model as pseudocode then loops, then vectorized NumPy.
Download
Topic 3 — Programming Basics
A two-period consumption-saving problem via an Agent class and scipy.optimize, then the same linear algebra in NumPy versus PyTorch.
Download
Topic 3A — Claude Code Starter Project
A scaffolded project to build a dynamic equilibrium model in, with convergence and Euler-error gates wired in from the start.
Download ZIP
Topic 4 — Numerical Methods
Root-finding for market equilibrium, constrained utility maximization with FOC validation, spline interpolation, and Tauchen discretization checked against simulated moments.
Download
Topic 5 — Machine Learning Basics
A neural net fitted to a known non-linear consumption function, with a hand-written PyTorch training loop and learning curves used to diagnose overfitting.
Download
Topic 5 — FOMC Minutes & the 10-Year Yield
Real data end to end: fetch from FRED, build features, fit, and read the result as an economist rather than as a modeller.
Download
Topic 6 — Dynamic Models A: the VFI benchmark
Classical grid-based value function iteration on the stochastic growth model — the "true" solution everything else is measured against.
Download
Topic 6 — Dynamic Models B: the neural-network solution
A ValueNet and a PolicyNet trained by alternating updates, overlaid on the Lab 6A solution to see how close it gets.
Download
Topic 7 — RBC with VFI and Time Iteration
Calibrate to US business-cycle moments, build grids, solve both ways, then simulate and compare the statistics.
Download
Topic 8 — Accelerated Methods & EGM
Howard's improvement and the endogenous grid method, with Euler equation errors mapped across the state space and sensitivity to grid density and tolerance.
Download
Topic 11 — Krusell-Smith in PyTorch
Aggregate uncertainty with the distribution as a state variable, solved with neural networks and checked for learning stability across iterations.
Download
Topic 12 — OLG Models
A stationary life-cycle model by backward induction and forward iteration, then extended with aggregate shocks and an embedded market-clearing layer. The largest lab — 107 cells.
Download

Topics 9 & 10 In preparation

Perturbation and Chebyshev projection (Topic 9) and parallelizing the VFI solver with MPI and PyTorch DDP (Topic 10) don't have notebooks yet. Both were worked through on camera in the meantime — see Lecture 7 of the 2026 recordings for perturbation and projection, and the Topic 10 deck for the HPC material, whose SLURM and mpi4py snippets are runnable as they stand.

Labs on language models and agents

Text-as-data, mini-GPT, RAG, and agentic research pipelines have their own labs on the sister course, AI for Economic Research — same CPU-only, offline-friendly setup.