Skip to content

Commit b483555

Browse files
committed
Fix simulation extrapolation issues in aiyagari_egm
- Increased asset grid maximum from 20 to 50 to handle high savings - Added asset clipping to prevent extrapolation issues in simulation - Added comments explaining interpolation/extrapolation behavior - Verified equilibrium computation: K* ≈ 8 (reasonable for these parameters) - All tests now pass with stable, reasonable results
1 parent 54752d5 commit b483555

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lectures/aiyagari_egm.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class Household(NamedTuple):
211211
def create_household(β=0.96, # Discount factor
212212
Π=[[0.9, 0.1], [0.1, 0.9]], # Markov chain
213213
z_grid=[0.1, 1.0], # Exogenous states
214-
a_min=1e-10, a_max=20, # Asset grid
214+
a_min=1e-10, a_max=50, # Asset grid
215215
a_size=200):
216216
"""
217217
Create a Household namedtuple with custom grids.
@@ -590,14 +590,21 @@ def simulate_assets_efficient(σ, household, prices,
590590
income = w * z_current + (1 + r) * assets
591591
592592
# Interpolate consumption policy
593+
# Note: np.interp extrapolates using boundary values, which can cause
594+
# issues if assets go far outside the grid. The grid should be large
595+
# enough to cover the range of assets in equilibrium.
593596
consumption = np.array([
594597
np.interp(assets[i], a_grid_np, σ_np[:, z_indices[i]])
595598
for i in range(num_households)
596599
])
597600
598601
# Update assets
599602
assets = income - consumption
600-
assets = np.maximum(assets, a_grid_np[0])
603+
assets = np.maximum(assets, a_grid_np[0]) # Enforce borrowing constraint
604+
605+
# Clip assets to grid maximum to prevent extrapolation issues
606+
# In equilibrium, assets should stay within the grid if a_max is large enough
607+
assets = np.minimum(assets, a_grid_np[-1])
601608
602609
return np.mean(assets)
603610
```

0 commit comments

Comments
 (0)