Skip to content

Commit

Permalink
Add a life-cycle example
Browse files Browse the repository at this point in the history
  • Loading branch information
Mv77 committed Jul 5, 2023
1 parent c4c5064 commit 11d7059
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions HARK/ConsumptionSaving/tests/test_ConsPortfolioModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,10 +307,39 @@ def test_draws(self):
self.assertTrue(np.all(Adjust_draws[t_age == 2] == 1))


from HARK.ConsumptionSaving.ConsIndShockModel import init_lifecycle
from HARK.ConsumptionSaving.ConsRiskyAssetModel import risky_asset_parms


class test_transition_mat(unittest.TestCase):
def setUp(self):
pass

def test_LC(self):
# Create an lc agent
lc_pars = copy(init_lifecycle)
lc_pars.update(risky_asset_parms)
agent = cpm.PortfolioConsumerType(**lc_pars)
agent.solve()

# Make shock distribution and grid
agent.make_shock_distributions()
agent.make_state_grid(
PLvlGrid=None,
# Low number of points, else RAM reqs are high
mNrmGrid=np.linspace(0, 10, 5),
ShareGrid=None,
AdjustGrid=None,
)
# Solve
agent.solve()
# Check that it is indeed an LC model
assert len(agent.solution) > 10

# Get transition matrices
agent.find_transition_matrices()
assert len(agent.solution) - 1 == len(agent.trans_mats)

def test_adjust(self):
# Create agent
agent = cpm.PortfolioConsumerType(**cpm.init_portfolio)
Expand Down

0 comments on commit 11d7059

Please sign in to comment.