|
513 | 513 | ```{code-cell} julia |
514 | 514 | function verify_true_policy(m, shocks, c_star) |
515 | 515 | # compute (Kc_star) |
516 | | - @unpack grid, β, ∂u∂c, f, f′ = m |
| 516 | + (;grid, β, ∂u∂c, f, f′) = m |
517 | 517 | c_star_new = K(c_star, grid, β, ∂u∂c, f, f′, shocks) |
518 | 518 |
|
519 | 519 | # plot c_star and Kc_star |
@@ -549,7 +549,7 @@ The initial condition we'll use is the one that eats the whole pie: $c(y) = y$ |
549 | 549 |
|
550 | 550 | ```{code-cell} julia |
551 | 551 | function check_convergence(m, shocks, c_star, g_init; n_iter = 15) |
552 | | - @unpack grid, β, ∂u∂c, f, f′ = m |
| 552 | + (;grid, β, ∂u∂c, f, f′) = m |
553 | 553 | g = g_init; |
554 | 554 | plot(m.grid, g, lw = 2, alpha = 0.6, label = L"intial condition $c(y) = y$") |
555 | 555 | for i in 1:n_iter |
@@ -595,7 +595,7 @@ function iterate_updating(func, arg_init; sim_length = 20) |
595 | 595 | end |
596 | 596 |
|
597 | 597 | function compare_error(m, shocks, g_init, w_init; sim_length = 20) |
598 | | - @unpack grid, β, u, ∂u∂c, f, f′ = m |
| 598 | + (;grid, β, u, ∂u∂c, f, f′) = m |
599 | 599 | g, w = g_init, w_init |
600 | 600 |
|
601 | 601 | # two functions for simplification |
@@ -742,7 +742,7 @@ m_ex = Model(γ = 1.5); |
742 | 742 | ```{code-cell} julia |
743 | 743 | function exercise2(m, shocks, g_init = m.grid, w_init = m.u.(m.grid); sim_length = 20) |
744 | 744 |
|
745 | | - @unpack grid, β, u, ∂u∂c, f, f′ = m |
| 745 | + (;grid, β, u, ∂u∂c, f, f′) = m |
746 | 746 | # initial policy and value |
747 | 747 | g, w = g_init, w_init |
748 | 748 | # iteration |
@@ -773,12 +773,12 @@ It assumes that you've just run the code from the previous exercise |
773 | 773 |
|
774 | 774 | ```{code-cell} julia |
775 | 775 | function bellman(m, shocks) |
776 | | - @unpack grid, β, u, ∂u∂c, f, f′ = m |
| 776 | + (;grid, β, u, ∂u∂c, f, f′) = m |
777 | 777 | bellman_single_arg(w) = T(w, grid, β, u, f, shocks) |
778 | 778 | iterate_updating(bellman_single_arg, u.(grid), sim_length = 20) |
779 | 779 | end |
780 | 780 | function coleman(m, shocks) |
781 | | - @unpack grid, β, ∂u∂c, f, f′ = m |
| 781 | + (;grid, β, ∂u∂c, f, f′) = m |
782 | 782 | coleman_single_arg(g) = K(g, grid, β, ∂u∂c, f, f′, shocks) |
783 | 783 | iterate_updating(coleman_single_arg, grid, sim_length = 20) |
784 | 784 | end |
|
0 commit comments