An addition to this model that @jorgebarro is working on is to incorporate stochastic income processes into the model. This necessitates changing the solution method and thus some of the structure of the computational solutions. This issue discusses the entry points into the OG-USA source code for modules/functions that will allow for stochastic income processes to be included into the model.
In household.py:
Essentially every function can be removed.
New functions will include those necessary to solve the problem of an individual household.
e.g., if we look at this code, an updated household.py would include the functions solve_agent() and solve_value() (and perhaps solve_cohort())
One will also want a function that defines the utility function of the agent so that is can be changed easily.
Because household solution would now rely on methods that involve solving the problem over a discrete grid, the household solution would return policy functions defining savings and labor supply for each point on that grid. These would be used together with the distribution of the population over these grid points to solve for economic aggregates. Thus in aggregates.py, all functions would need to be updated to sum across these grids, where the sums include the sum weighted implied by the distribution of agents over the grid points in the capital-labor supply grids and over age (as given by the omega matrix (or array in the time path).
A new model should be created to store functions related to the computation of the distribution of agents over the grid points in the capital-labor supply state spaces. Such a module would include a function to solve for the stationary distribution over these grid points as well as over age. This function would take in the omega_SS matrix and the policy functions to find the stationary distribution for the steady state. Another function would compute the distribution over these points from the initial state over the time path using the omega array that gives the exogenous distribution of households by age over each period in the time path. These distributions would be used in the aggregation functions outlined above.
With the above in place, one would alter the OG-USA code in a few ways:
1) Update SS.py:
Remove euler_equation_solver()
In inner_loop(), replace lines 309-329 will calls to the relevant functions in household.py that solve the household problem and return policy functions
in inner_loop(), between lines 329 and 331, insert functions to compute the distribution of agents over the state space (capital, labor supply, age)
In inner_loop() in lines 331-379, update calls to functions that find economic aggregates to include what needs to be passed to these functions in the stochastic income case (i.e., grids and distributions)
In SS_solver(), update 533-636 to update calls to aggregate functions.
In run_SS(), one will want to change some things about initial values passed in to accord with the new solution method for the household problem.
2) Update TPI.py:
remove the firstdoughnutring() and twist_doughnut() functions.
update inner_loop() to replace lines 410-482 (and what is returned from the function) to work with the new household solution (where one will still loop over the time path in a way similar to the current structure - i.e., with the twist donut)
Update a lot in run_TPI -- e.g., will need to compute the distribution of the state space at each point on the time path, use updated functions to compute aggregates.
Note also:
One needs to be careful in stationarizing the value function used for the solution.
Obviously parameters passed to function calls throughout will likely need to be changed to reflect new parameters used to define the stochastic income process and characteristics of the solution method. This will include changes to parameters.py to define new parameters.
One will want to make smart use of starting values - e.g. solving for one agent type/cohort to help inform the starting value for the solution to the next cohort/type if they are solved serially.
There may be some things I left out, but this should help in conceptualizing how the stochastic income solution method will enter the current model.
An addition to this model that @jorgebarro is working on is to incorporate stochastic income processes into the model. This necessitates changing the solution method and thus some of the structure of the computational solutions. This issue discusses the entry points into the OG-USA source code for modules/functions that will allow for stochastic income processes to be included into the model.
In
household.py
:household.py
would include the functionssolve_agent()
andsolve_value()
(and perhapssolve_cohort()
)Because household solution would now rely on methods that involve solving the problem over a discrete grid, the household solution would return policy functions defining savings and labor supply for each point on that grid. These would be used together with the distribution of the population over these grid points to solve for economic aggregates. Thus in
aggregates.py
, all functions would need to be updated to sum across these grids, where the sums include the sum weighted implied by the distribution of agents over the grid points in the capital-labor supply grids and over age (as given by theomega
matrix (or array in the time path).A new model should be created to store functions related to the computation of the distribution of agents over the grid points in the capital-labor supply state spaces. Such a module would include a function to solve for the stationary distribution over these grid points as well as over age. This function would take in the
omega_SS
matrix and the policy functions to find the stationary distribution for the steady state. Another function would compute the distribution over these points from the initial state over the time path using theomega
array that gives the exogenous distribution of households by age over each period in the time path. These distributions would be used in the aggregation functions outlined above.With the above in place, one would alter the OG-USA code in a few ways: 1) Update
SS.py
:euler_equation_solver()
inner_loop()
, replace lines 309-329 will calls to the relevant functions in household.py that solve the household problem and return policy functionsinner_loop()
, between lines 329 and 331, insert functions to compute the distribution of agents over the state space (capital, labor supply, age)inner_loop()
in lines 331-379, update calls to functions that find economic aggregates to include what needs to be passed to these functions in the stochastic income case (i.e., grids and distributions)SS_solver()
, update 533-636 to update calls to aggregate functions.run_SS()
, one will want to change some things about initial values passed in to accord with the new solution method for the household problem.2) Update
TPI.py
:firstdoughnutring()
andtwist_doughnut()
functions.inner_loop()
to replace lines 410-482 (and what is returned from the function) to work with the new household solution (where one will still loop over the time path in a way similar to the current structure - i.e., with the twist donut)run_TPI
-- e.g., will need to compute the distribution of the state space at each point on the time path, use updated functions to compute aggregates.Note also:
parameters.py
to define new parameters.There may be some things I left out, but this should help in conceptualizing how the stochastic income solution method will enter the current model.
cc @rickecon