shade-econ / sequence-jacobian

A unified framework to solve and analyze heterogeneous-agent macro models.
MIT License
253 stars 149 forks source link

Hetoutput in the Krusel Smith tutorial #25

Closed GuiAll closed 4 months ago

GuiAll commented 4 months ago

Hello everyone

I am learning how to build code with the SSJ with the tutorials (very useful, thanks !). I am trying to figure out where the code generates the (aggregate) outputs A and C :

@het(exogenous='Pi', policy='a', backward='Va', backward_init=household_init) def household(Va_p, a_grid, e_grid, r, w, beta, eis): """Single backward iteration step using endogenous gridpoint method for households with CRRA utility.

Parameters
----------
Va_p     : array (nE, nA), expected marginal value of assets next period
a_grid   : array (nA), asset grid
e_grid   : array (nE), producticity grid
r        : scalar, ex-post real interest rate
w        : scalar, wage
beta     : scalar, discount factor
eis      : scalar, elasticity of intertemporal substitution

Returns
----------
Va : array (nE, nA), marginal value of assets today
a  : array (nE, nA), asset policy today
c  : array (nE, nA), consumption policy today
"""
uc_nextgrid = beta * Va_p
c_nextgrid = uc_nextgrid ** (-eis)
coh = (1 + r) * a_grid[np.newaxis, :] + w * e_grid[:, np.newaxis]
a = interpolate.interpolate_y(c_nextgrid + a_grid, coh, a_grid)
misc.setmin(a, a_grid[0])
c = coh - a
Va = (1 + r) * c ** (-1 / eis)
return Va, a, c

However, I do not see any hetoutput that generates A and C from a and c. Is it automatically calculated as part of the HetBlock ? In which case I presume that these macro output are automatically named as capital [name of the corresponding micro input] ? Or am I missing something ?

Thank you in advance !

bbardoczy commented 4 months ago

You're right.