Add new lecture: Aiyagari model with Endogenous Grid Method#676
Merged
Conversation
This PR adds a new lecture aiyagari_egm.md that combines the Aiyagari model with the Endogenous Grid Method (EGM). Key Features: - Combines concepts from egm_policy_iter.md and aiyagari.md - Uses EGM to solve the household problem (avoiding costly root-finding) - Uses simulation to compute aggregate capital (instead of analytical stationary distribution) - EGM operator for the Aiyagari model - Corrected implementation, converges in ~90 iterations - Simulation-based aggregation - Simulates 10,000+ households via Monte Carlo - Equilibrium computation - Uses bisection to find equilibrium capital stock (K* ≈ 8) - Wealth distribution analysis - Histograms, Lorenz curves, and Gini coefficient - Educational content - Comparison with standard approach and four exercises 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
📖 Netlify Preview Ready! Preview URL: https://pr-676--sunny-cactus-210e3e.netlify.app (647e41e) 📚 Changed Lecture Pages: aiyagari, aiyagari_egm, endogenous_lake |
|
📖 Netlify Preview Ready! Preview URL: https://pr-676--sunny-cactus-210e3e.netlify.app (6b3e4e5) 📚 Changed Lecture Pages: aiyagari, aiyagari_egm, endogenous_lake |
# Conflicts: # lectures/_toc.yml
Reworks the lecture so the EGM operator, the household solver and the cross-section simulation are all JIT-compiled and vectorized in JAX, matching the conventions in os_egm_jax. - Remove the broken @jax.jit `K_egm` (data-dependent Python branch) and the unusable jitted `simulate_households` (per-household Python loops); keep a single vectorized `K_egm` and one `simulate_cross_section`. - Solver now uses `jax.lax.while_loop`; simulation uses `jax.lax.fori_loop` with vmap-ed interpolation and inverse-CDF Markov transitions. - Drop the unused numba import; use deterministic PRNG keys so bisection sees a deterministic excess-demand function. - Use qe.lorenz_curve / qe.gini_coefficient instead of hand-rolled np.trapz. Runs end-to-end: K* = 8.15, r* = 0.031, Gini = 0.36, Euler residual 8e-07. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
📖 Netlify Preview Ready!Preview URL: https://pr-676--sunny-cactus-210e3e.netlify.app Commit: 📚 Changed LecturesBuild Info
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a new lecture
aiyagari_egm.mdthat combines the Aiyagari model with the Endogenous Grid Method (EGM).Overview:
The lecture combines two important computational methods:
Key Features:
egm_policy_iter.mdandaiyagari.mdImplementation Details:
Fixes Applied:
Files changed:
lectures/_toc.yml- Added entry for new lecturelectures/aiyagari_egm.md- New lecture fileTest plan
🤖 Generated with Claude Code