Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add parameters back to ConsLaborModel and fix up to match new distribution code #729

Merged
merged 5 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 28 additions & 5 deletions HARK/ConsumptionSaving/ConsLaborModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ def solveConsLaborIntMarg(solution_next,PermShkDstn,TranShkDstn,LivPrb,DiscFac,C

# Unpack next period's solution and the productivity shock distribution, and define the inverse (marginal) utilty function
vPfunc_next = solution_next.vPfunc
TranShkPrbs = TranShkDstn[0]
TranShkVals = TranShkDstn[1]
PermShkPrbs = PermShkDstn[0]
PermShkVals = PermShkDstn[1]
TranShkPrbs = TranShkDstn.pmf
TranShkVals = TranShkDstn.X
PermShkPrbs = PermShkDstn.pmf
PermShkVals = PermShkDstn.X
TranShkCount = TranShkPrbs.size
PermShkCount = PermShkPrbs.size
uPinv = lambda X : CRRAutilityP_inv(X,gam=CRRA)
Expand Down Expand Up @@ -451,7 +451,7 @@ def updateTranShkGrid(self):
'''
TranShkGrid = [] # Create an empty list for TranShkGrid that will be updated
for t in range(self.T_cycle):
TranShkGrid.append(self.TranShkDstn[t][1]) # Update/ Extend the list of TranShkGrid with the TranShkVals for each TranShkPrbs
TranShkGrid.append(self.TranShkDstn[t].X) # Update/ Extend the list of TranShkGrid with the TranShkVals for each TranShkPrbs
self.TranShkGrid = TranShkGrid # Save that list in self (time-varying)
self.addToTimeVary('TranShkGrid') # Run the method addToTimeVary from AgentType to add TranShkGrid as one parameter of time_vary list

Expand Down Expand Up @@ -596,3 +596,26 @@ def plotLbrFunc(self,t,bMin=None,bMax=None,ShkSet=None):
plt.xlabel('Beginning of period bank balances')
plt.ylabel('Labor supply')
plt.show()

# Make a default dictionary for the intensive margin labor supply model
init_labor_intensive = copy(init_idiosyncratic_shocks)
init_labor_intensive ['LbrCostCoeffs'] = [-1.0]
init_labor_intensive ['WageRte'] = [1.0]
init_labor_intensive['IncUnemp'] = 0.0
init_labor_intensive['TranShkCount'] = 15 # Crank up permanent shock count - Number of points in discrete approximation to transitory income shocks
init_labor_intensive['PermShkCount'] = 16 # Crank up permanent shock count
init_labor_intensive ['aXtraCount'] = 200 # May be important to have a larger number of gridpoints (than 48 initially)
init_labor_intensive ['aXtraMax'] = 80.
init_labor_intensive ['BoroCnstArt'] = None

# Make a dictionary for qintensive margin labor supply model with finite lifecycle
init_labor_lifecycle = init_labor_intensive.copy()
init_labor_lifecycle['PermGroFac'] = [1.01,1.01,1.01,1.01,1.01,1.02,1.02,1.02,1.02,1.02]
init_labor_lifecycle['PermShkStd'] = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]
init_labor_lifecycle['TranShkStd'] = [0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1,0.1]
init_labor_lifecycle['LivPrb'] = [0.99,0.9,0.8,0.7,0.6,0.5,0.4,0.3,0.2,0.1] # Living probability decreases as time moves forward.
init_labor_lifecycle['WageRte'] = [1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0] # Wage rate in a lifecycle
init_labor_lifecycle['LbrCostCoeffs'] = [-2.0, 0.4] # Assume labor cost coeffs is a polynomial of degree 1
init_labor_lifecycle['T_cycle'] = 10
#init_labor_lifecycle['T_retire'] = 7 # IndexError at line 774 in interpolation.py.
init_labor_lifecycle['T_age'] = 11 # Make sure that old people die at terminal age and don't turn into newborns!
21 changes: 21 additions & 0 deletions HARK/ConsumptionSaving/tests/test_ConsLaborModel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from HARK.ConsumptionSaving.ConsLaborModel import (
LaborIntMargConsumerType,
init_labor_lifecycle,
)
import unittest


class test_LaborIntMargConsumerType(unittest.TestCase):
def setUp(self):
self.model = LaborIntMargConsumerType()
self.model_finte_lifecycle = LaborIntMargConsumerType(**init_labor_lifecycle)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

finte -> finite ?

self.model_finte_lifecycle.cycles = 1

def test_solution(self):
self.model.solve()
self.model_finte_lifecycle.solve()

self.model.T_sim = 120
self.model.track_vars = ["bNrmNow", "cNrmNow"]
self.model.initializeSim()
self.model.simulate()
3 changes: 1 addition & 2 deletions examples/ConsumptionSaving/example_ConsLaborModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
do_simulation = True

# Make and solve a labor intensive margin consumer i.e. a consumer with utility for leisure
LaborIntMargExample = LaborIntMargConsumerType()
LaborIntMargExample = LaborIntMargConsumerType(verbose=0)
LaborIntMargExample.cycles = 0

t_start = process_time()
Expand Down Expand Up @@ -134,7 +134,6 @@
end_time = process_time()
print('Solving a lifecycle labor intensive margin consumer took ' + str(end_time-start_time) + ' seconds.')
LifecycleExample.unpackcFunc()
LifecycleExample.timeFwd()

bMax = 20.

Expand Down