In this exercise you continue building up the deaton()
class by adding the finite horizon version of the model.
Start by copying the deaton()
class code from lecture notebook 36. Make the following modifications:
__repr__()
method to output whether the model is finite or infinite horizonsolver_backwards_induction()
with the only argument callback function (but using horizon attribute for the maximum number of periods). See lecture notebook 27 for examples of backward induction solversRun separate simulations of the model for a few values of parameters, and discuss their similarities and differences.
# Your code here
m = deaton(ngrid=100,nchgrid=250,sigma=.2,R=1.05,beta=.975,nquad=10)
m.horizon=12
print(m)
v,c = m.solve_plot(solver='vfi')
sims = m.simulator(init_wealth=[1,2,3],T=5)