Skip to content

Commit 09d9208

Browse files
authored
[ak_aiyagari] Refactor household variable references in functions
This PR resolves a naming inconsistency and potential bug across several functions where a global variable hh was referenced instead of the household argument passed into the function. This issue affects several key components of the model's implementation, including find_ss, popu_dist, compute_aggregates, and others.
1 parent a137f5d commit 09d9208

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

lectures/ak_aiyagari.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -524,8 +524,8 @@ def popu_dist(σ, household, Q):
524524
525525
j_grid, a_grid, γ_grid, Π, β, init_μ, VJ = household
526526
527-
J = hh.j_grid.size
528-
num_state = hh.a_grid.size * hh.γ_grid.size
527+
J = household.j_grid.size
528+
num_state = household.a_grid.size * household.γ_grid.size
529529
530530
def update_popu_j(μ_j, j):
531531
"Update population distribution from age j to j+1"
@@ -626,7 +626,7 @@ def compute_aggregates(μ, household):
626626
627627
J, a_size, γ_size = j_grid.size, a_grid.size, γ_grid.size
628628
629-
μ = μ.reshape((J, hh.a_grid.size, hh.γ_grid.size))
629+
μ = μ.reshape((J, household.a_grid.size, household.γ_grid.size))
630630
631631
# Compute private savings
632632
a = a_grid.reshape((1, a_size, 1))
@@ -693,13 +693,13 @@ def find_ss(household, firm, pol_target, Q, tol=1e-6, verbose=False):
693693
r_old, w_old, τ_old = r, w, τ
694694
695695
# Household optimal decisions and values
696-
V, σ = backwards_opt([r, w], [τ, δ], hh, Q)
696+
V, σ = backwards_opt([r, w], [τ, δ], household, Q)
697697
698698
# Compute the stationary distribution
699-
μ = popu_dist(σ, hh, Q)
699+
μ = popu_dist(σ, household, Q)
700700
701701
# Compute aggregates
702-
A, L = compute_aggregates(μ, hh)
702+
A, L = compute_aggregates(μ, household)
703703
K = A - D
704704
705705
# Update prices
@@ -860,8 +860,8 @@ def population_evolution(σt, μt, household, Q):
860860
861861
j_grid, a_grid, γ_grid, Π, β, init_μ, VJ = household
862862
863-
J = hh.j_grid.size
864-
num_state = hh.a_grid.size * hh.γ_grid.size
863+
J = household.j_grid.size
864+
num_state = household.a_grid.size * household.γ_grid.size
865865
866866
def population_evolution_j(j):
867867
@@ -997,7 +997,7 @@ def path_iteration(ss1, ss2, pol_target, household, firm, Q, tol=1e-4, verbose=F
997997
998998
# Solve optimal policies backwards
999999
V_seq, σ_seq = solve_backwards(
1000-
V_ss2, σ_ss2, hh, firm, price_seq, pol_seq, Q)
1000+
V_ss2, σ_ss2, household, firm, price_seq, pol_seq, Q)
10011001
10021002
# Compute population evolution forwards
10031003
μ_seq, K_seq, L_seq = simulate_forwards(

0 commit comments

Comments
 (0)