Skip to content

Commit

Permalink
Using default params in initializer for classes in ConsPrefShockModel
Browse files Browse the repository at this point in the history
  • Loading branch information
sbenthall committed Jan 3, 2020
1 parent ef22a5b commit 42a3d0a
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions HARK/ConsumptionSaving/ConsPrefShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from HARK.ConsumptionSaving.ConsIndShockModel import IndShockConsumerType, ConsumerSolution, ConsIndShockSolver, \
ValueFunc, MargValueFunc, KinkedRconsumerType, ConsKinkedRsolver
from HARK.interpolation import LinearInterpOnInterp1D, LinearInterp, CubicInterp, LowerEnvelope
import HARK.ConsumptionSaving.ConsumerParameters as Params

class PrefShockConsumerType(IndShockConsumerType):
'''
Expand All @@ -23,7 +24,10 @@ class PrefShockConsumerType(IndShockConsumerType):
'''
shock_vars_ = IndShockConsumerType.shock_vars_ + ['PrefShkNow']

def __init__(self,cycles=1,time_flow=True,**kwds):
def __init__(self,
cycles=1,
time_flow=True,
**kwds):
'''
Instantiate a new ConsumerType with given data, and construct objects
to be used during solution (income distribution, assets grid, etc).
Expand All @@ -41,7 +45,14 @@ def __init__(self,cycles=1,time_flow=True,**kwds):
-------
None
'''
IndShockConsumerType.__init__(self,cycles=cycles,time_flow=time_flow,**kwds)
params = Params.init_preference_shocks.copy()
params.update(kwds)
kwds = params

IndShockConsumerType.__init__(self,
cycles=cycles,
time_flow=time_flow,
**kwds)
self.solveOnePeriod = solveConsPrefShock # Choose correct solver

def preSolve(self):
Expand Down Expand Up @@ -206,6 +217,9 @@ def __init__(self,cycles=1,time_flow=True,**kwds):
-------
None
'''
params = Params.init_kinky_pref.copy()
params.update(kwds)
kwds = params
IndShockConsumerType.__init__(self,**kwds)
self.solveOnePeriod = solveConsKinkyPref # Choose correct solver
self.addToTimeInv('Rboro','Rsave')
Expand Down Expand Up @@ -600,7 +614,6 @@ def solveConsKinkyPref(solution_next,IncomeDstn,PrefShkDstn,
###############################################################################

def main():
import HARK.ConsumptionSaving.ConsumerParameters as Params
import matplotlib.pyplot as plt
from HARK.utilities import plotFuncs
from time import clock
Expand All @@ -609,7 +622,7 @@ def main():
do_simulation = True

# Make and solve a preference shock consumer
PrefShockExample = PrefShockConsumerType(**Params.init_preference_shocks)
PrefShockExample = PrefShockConsumerType()
PrefShockExample.cycles = 0 # Infinite horizon

t_start = clock()
Expand Down Expand Up @@ -652,7 +665,7 @@ def main():
###########################################################################

# Make and solve a "kinky preferece" consumer, whose model combines KinkedR and PrefShock
KinkyPrefExample = KinkyPrefConsumerType(**Params.init_kinky_pref)
KinkyPrefExample = KinkyPrefConsumerType()
KinkyPrefExample.cycles = 0 # Infinite horizon

t_start = clock()
Expand Down

0 comments on commit 42a3d0a

Please sign in to comment.