Closed caimichael closed 3 years ago
Updated with fixes to notebook code and unit tests! Released as the patch v0.2.1
I will introduce these changes onto a new branch in the repository for now, so as to not disrupt work currently happening on the `develop' branch
New features
A basic package structure to be able to utilize the
sequence_jacobian
as a python package. Top-level functions and modules located withinsequence_jacobian/__init__.py
.steady_state
, which automatically solves for the steady state values of the parameters/variables for a given model specification, e.g. a set of blocks, fixed parameter/variable values, unknowns, and targets.Implemented a rudimentary new block type,
HelperBlock
, which allows users to include partial steady state solutions as a "block" in theblocks
argument provided tosteady_state
to speed up the computation of the rest of the steady state values, e.g. in the Krusell Smith model, the firm's problem can be solved sosteady_state
effectively only needs to solve the household problem.Enhanced
SimpleBlock
with more flexible displacement handlers (Ignore
,Displace
, and the newly implementedIgnoreVector
andAccumulatedDerivative
[replacingReporter
andPerturb
]) to allow for more general specifications of equations within aSimpleBlock
.This includes the ability to call time displacements on variables newly defined within a
SimpleBlock
, to evaluate variables using arbitrary functions—single-argument functions are called by invoking the.apply(f)
method of any variable within aSimpleBlock
, and multi-argument functions are called by invokingapply_function(*args)
—while maintaining displacement-relevant information, and to write equations that involve arbitrary compositions of newly-defined variables with input arguments into theSimpleBlock
.A pytest testing suite located in
sequence_jacobian/tests/base
, which unit tests for the basic functionality of the Sequence Space Jacobian package. This includes testing most of the computations displaced in the Jupyter notebooks included with this package.hetoutput
—functions of the individual-level policy variables from a givenHetBlock
—can now be included as outputs users get from steady state and transitional dynamic computations by using theadd_hetoutput
features insequence_jacobian/blocks/het_block.py
. Currentlyhetoutput
are limited to being the same dimension as the cross-sectional distributionD
and hence there is no capability for "custom" aggregation of hetoutputs. All hetoutputs are aggregated linearly acrossD
, just as the standard individual-level policy variables are aggregated acrossD
.An example of a
hetoutput
is theadjustment_costs
of agents across the two-dimensional asset distribution in the two asset HANK model located insequence_jacobian/models/two_asset.py
. Thishetoutput
can be added to the household block usinghousehold.add_hetoutput(adjustment_costs)
.Work-in-progress features
These features exist in the code currently but in an unfinished state.
CombinedBlock
insequence_jacobian/blocks/combined_block.py
currently works when included in the set of blocks called insteady_state
i, i.e..ss
for a concrete instance of the block works; however, transitional dynamics (.td
) and calculation of the Jacobian (.jac
) have yet to be implemented.HelperBlock
insequence_jacobian/blocks/helper_block.py
currently works when included in the set of blocks for steady state, transitional dynamics, and Jacobian calculations; however, most of its functionality is not contained within theHelperBlock
class itself, but rather in other code such asblock_sort
, which checks if blocks are ofHelperBlock
when deciding how to conduct the sort. May revisit the design principle behind having a block that is virtually identical to aSimpleBlock
albeit with more limited abilities as a stand-alone class simple as a way for methods to inspect differently.Block
, andModel
insequence_jacobian/primitives.py
are meant to be abstract base classes to provide more unifying concepts within the Sequence Space Jacobian package.sequence_jacobian/tests/performance
and more granular unit tests insequence_jacobian/tests/base
andsequence_jacobian/tests/robustness
.Breaking changes
In particular,
sequence_jacobian/utils.py
has been broken up into separate modules contained in thesequence_jacobian/utilities
directory to make it easier for users to locate utilities and define new ones.SimpleSparse
class tosequence_jacobian/jacobian.py
noisy
, set toTrue
if the user wanted a particular function to provide print statements of its functionality, toverbose
to be more descriptive.attach_hetinput
toadd_hetinput
and instead of returning a new instance of theHetBlock
, it modifies the existingHetBlock
in place. Noteadd_hetinput
has anoverwrite
kwarg to allow users to switch out existing hetinputs for new ones.non_back_outputs
->non_back_iter_outputs
, andinputs_p
->inputs_to_be_primed
.