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 :
The HetBlock scripted in cell 7 and characterized by the backward step generates as outputs Va (the value function), a (the policy for assets) and c (the policy for consumption), i.e. multidimensionnal outputs. The script is :
@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
the outputs stated for the households on cell 8, called by print(f'Macro outputs: {household.outputs}') indicate A and 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 ?
Both the core backward iteration function (household in your example) and any hetoutput functions that may be attached to it return micro outputs on the grid. Let's call these policies.
The convention is that policies are lower case. You get an error message if you violate this convention.
Policies are automatically aggregated under the hood. The convention is that aggregate outputs have the same name as the policy, just upper case.
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.
print(f'Macro outputs: {household.outputs}')
indicate A and CHowever, 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 !