QuantEcon · GitHub

Commit 30c2e5c

jstacclaude

and

authored

Add transient income innovation to IFP model and wealth inequality analysis (#745)

* teaked timing discussion in ifp_egm * Add transient income innovation to IFP model and wealth inequality analysis This commit modifies the income fluctuation problem (IFP) model to include a transient IID income shock, following the specification in ifp_advanced. Changes to ifp_egm.md: 1. Income process modification: - Changed from Y_t = exp(Z_t) to Y_t = exp(a_y * η_t + Z_t * b_y) - Added IID shock η_t ~ N(0,1) to create transient income fluctuations - Updated Euler equation to integrate over η shocks using Monte Carlo - Kept interest rate R constant throughout (as specified) 2. Implementation updates: - Added parameters a_y=0.2, b_y=0.5, shock_draw_size=100 - Updated NumPy implementation with numba.jit optimization - Updated JAX implementation with separate utility functions - Modified simulation code to draw η shocks during dynamics - Updated all code cells to unpack new IFP parameters 3. New wealth inequality analysis section: - Added Gini coefficient computation - Added top 1% wealth share computation - Analyzed how inequality varies with interest rate r - Tested 12 interest rate values from 0 to 0.015 - Generated plots showing Gini and top 1% vs interest rate 4. Performance optimization: - Added @numba.jit decorators to u_prime, u_prime_inv, Y, and K_numpy - Created separate JAX versions to avoid numba/JAX conflicts Changes to ifp_advanced.md: - Updated shock_draw_size from 50 to 100 in both Numba and JAX implementations The modifications maintain consistency with ifp_advanced while keeping R constant in ifp_egm. The transient income shock creates more realistic wealth inequality through increased precautionary savings. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Refactor ifp_egm: use JAX throughout and improve code organization - Convert Gini coefficient and top share calculations from NumPy to JAX - Embed utility functions (u_prime, u_prime_inv) and income function (y) inside K_numpy and K operators to simplify function signatures - Introduce z_prime variable for better readability in nested loops - Fix y_bar(k) to correctly implement mathematical definition of expected labor income conditional on current state - Use vmap for vectorization in y_bar computation - Remove redundant y_mean vector in favor of direct y_bar(k) calls 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Fix simulate_household to use embedded y function - Add local y function inside simulate_household to replace removed y_jax - Maintains consistency with refactoring pattern used in K_numpy and K - All tests pass successfully 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> * Improve ifp_egm lecture: add JAX dependency, fix grammar, enhance documentation - Add jax to pip install requirements - Improve y_bar function docstring with clearer mathematical notation - Fix grammar and consistency in introduction - Add spacing in K_numpy function for readability 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>

2 files changed

Lines changed: 376 additions & 116 deletions

File tree

  • lectures

Lines changed: 2 additions & 2 deletions

Original file line numberDiff line numberDiff line change

@@ -376,7 +376,7 @@ class IFP:

376376

b_r=0.0,

377377

a_y=0.2,

378378

b_y=0.5,

379-

shock_draw_size=50,

379+

shock_draw_size=100,

380380

grid_max=10,

381381

grid_size=100,

382382

seed=1234):

@@ -665,7 +665,7 @@ def create_ifp_jax(γ=1.5,

665665

b_r=0.0,

666666

a_y=0.2,

667667

b_y=0.5,

668-

shock_draw_size=50,

668+

shock_draw_size=100,

669669

grid_max=10,

670670

grid_size=100,

671671

seed=1234):

Read the original on github.com ↗