Labs

The notebooks ship with no stored output, on purpose. You are meant to produce the numbers, not read them. Every cell runs on a laptop CPU in well under a minute; no GPU is needed in this course before Session 7.

Getting set up

git clone https://github.com/vonzhg/Macro-2026Fall.git
cd Macro-2026Fall
conda create -n econ282e python=3.11 -y
conda activate econ282e
pip install -r labs/requirements.txt
jupyter lab

Or use any environment that satisfies requirements.txt. GitHub renders .ipynb files in the browser if you only want to read one.

Notebooks

Lab 0 — Getting Started Available Download .ipynb

Posted before Session 3. Installs the tools, verifies the environment, writes a first program, and solves the Solow model against its closed form. Start here if you have never used Python.

Lab 3 — Python and Value Function Iteration Available Download .ipynb

Session 3 (Oct 8). Python and NumPy essentials; the GrowthModel class; VFI and time iteration, both graded against the Brock–Mirman closed form; convergence and accuracy diagnostics; a dependency-free HP filter; a first look at autograd. Homework 1 Part A starts from this lab.

Lab 4 — Numerical Methods Available Download .ipynb

Session 4 (Oct 15). A root-finder bake-off with measured convergence orders (1, 1.618, 2); golden section; interpolation shape tests and Smolyak sparse grids; quadrature; Tauchen against Rouwenhorst at ρ = 0.9, 0.95, 0.99; Howard and EGM on the quarterly RBC model; and the deck 4.B4 worked example end to end.

Lab 5 — Perturbation and Projection Available Download .ipynb

Session 5 (Oct 22). Log-linearization and the QZ solve, with Blanchard–Kahn as an eigenvalue count; the Taylor principle recovered from a New Keynesian model; second order by residual matching, the risk correction and pruning; the Hilbert matrix at condition 3×1018; Chebyshev conditioning and convergence; a collocation solve of the same RBC model; and one model, four methods.

Lab 6 — Aiyagari, End to End Available Download .ipynb

Session 6 (Oct 29). The household problem by EGM and the kink the borrowing limit puts in it; the Young lottery and three routes to the invariant distribution; bisection on r, and why Newton is the wrong tool here; a refinement ladder and Euler residuals reported as a median, with the maximum located; persistence moving the constrained share from 0.5% to 13% with dispersion held fixed; a capital-tax transition solved backward-then-forward; welfare by consumption-equivalent variation, along the path and across steady states; and the complete-markets case where none of it was needed. The solver is inlined from the same code that generated the lecture's numbers.

Lab 7 — Machine Learning, and a Macro Model as a Loss Function Available Download .ipynb

Session 7 (Nov 5). A sum of shifted ReLUs fitted to sin x by least squares, and then with the kinks allowed to move — on a kinked target the learned knot lands on the constraint; the five-line training loop; backpropagation by hand checked against autograd; the growth model written as a loss and graded against its closed form; the quarterly RBC graded on off-sample Euler residuals; and an input-convex network against a plain one. First lab where a GPU helps — still not needed.

Labs 8–10 In preparation

Reinforcement learning; text as data; an agentic research workflow. Posted as each session is built.

If a cell fails, check the package versions first (pip install -r requirements.txt). Everything runs offline except the FRED downloads in deck 3.B4 and Homework 1 (Part A, A3), which need an internet connection; pandas-datareader is an optional alternative to reading FRED's CSV address directly.