Skip to content

Commit

Permalink
removing act_T from default Cobb-Douglas parameters because it's alre…
Browse files Browse the repository at this point in the history
…ady in __init__
  • Loading branch information
sbenthall committed Jan 4, 2020
1 parent 42a3d0a commit ed017fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 10 deletions.
39 changes: 30 additions & 9 deletions HARK/ConsumptionSaving/ConsAggShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
from HARK import HARKobject, Market, AgentType
from copy import deepcopy
import matplotlib.pyplot as plt
import HARK.ConsumptionSaving.ConsumerParameters as Params


utility = CRRAutility
utilityP = CRRAutilityP
Expand Down Expand Up @@ -79,6 +81,9 @@ def __init__(self, time_flow=True, **kwds):
Make a new instance of AggShockConsumerType, an extension of
IndShockConsumerType. Sets appropriate solver and input lists.
'''
params = Params.init_agg_shocks.copy()
params.update(kwds)
kwds = params
AgentType.__init__(self, solution_terminal=deepcopy(IndShockConsumerType.solution_terminal_),
time_flow=time_flow, pseudo_terminal=False, **kwds)

Expand Down Expand Up @@ -375,6 +380,9 @@ class AggShockMarkovConsumerType(AggShockConsumerType):
state is subject to Markov-style discrete state evolution.
'''
def __init__(self, **kwds):
params = Params.init_agg_mrkv_shocks.copy()
params.update(kwds)
kwds = params
AggShockConsumerType.__init__(self, **kwds)
self.addToTimeInv('MrkvArray')
self.solveOnePeriod = solveConsAggMarkov
Expand Down Expand Up @@ -886,7 +894,11 @@ class CobbDouglasEconomy(Market):
Note: The current implementation assumes a constant labor supply, but
this will be generalized in the future.
'''
def __init__(self, agents=[], tolerance=0.0001, act_T=1000, **kwds):
def __init__(self,
agents=[],
tolerance=0.0001,
act_T=1200,
**kwds):
'''
Make a new instance of CobbDouglasEconomy by filling in attributes
specific to this kind of market.
Expand All @@ -906,6 +918,9 @@ def __init__(self, agents=[], tolerance=0.0001, act_T=1000, **kwds):
-------
None
'''
params = Params.init_cobb_douglas.copy()
params.update(kwds)
kwds = params
Market.__init__(self, agents=agents,
sow_vars=['MaggNow', 'AaggNow', 'RfreeNow',
'wRteNow', 'PermShkAggNow', 'TranShkAggNow', 'KtoLnow'],
Expand Down Expand Up @@ -1330,7 +1345,11 @@ class CobbDouglasMarkovEconomy(CobbDouglasEconomy):
productivity growth factor can vary over time.
'''
def __init__(self, agents=[], tolerance=0.0001, act_T=1000, **kwds):
def __init__(self,
agents=[],
tolerance=0.0001,
act_T=1200,
**kwds):
'''
Make a new instance of CobbDouglasMarkovEconomy by filling in attributes
specific to this kind of market.
Expand All @@ -1350,6 +1369,9 @@ def __init__(self, agents=[], tolerance=0.0001, act_T=1000, **kwds):
-------
None
'''
params = Params.init_mrkv_cobb_douglas.copy()
params.update(kwds)
kwds = params
CobbDouglasEconomy.__init__(self, agents=agents, tolerance=tolerance, act_T=act_T, **kwds)
self.sow_vars.append('MrkvNow')

Expand Down Expand Up @@ -1773,7 +1795,6 @@ def __init__(self, AFunc):
###############################################################################

def main():
import HARK.ConsumptionSaving.ConsumerParameters as Params
from time import clock
from HARK.utilities import plotFuncs

Expand All @@ -1791,11 +1812,11 @@ def mystr(number): return "{:.4f}".format(number)

if solve_agg_shocks_micro or solve_agg_shocks_market:
# Make an aggregate shocks consumer type
AggShockExample = AggShockConsumerType(**Params.init_agg_shocks)
AggShockExample = AggShockConsumerType()
AggShockExample.cycles = 0

# Make a Cobb-Douglas economy for the agents
EconomyExample = CobbDouglasEconomy(agents=[AggShockExample], **Params.init_cobb_douglas)
EconomyExample = CobbDouglasEconomy(agents=[AggShockExample])
EconomyExample.makeAggShkHist() # Simulate a history of aggregate shocks

# Have the consumers inherit relevant objects from the economy
Expand Down Expand Up @@ -1842,12 +1863,12 @@ def mystr(number): return "{:.4f}".format(number)

if solve_markov_micro or solve_markov_market or solve_krusell_smith:
# Make a Markov aggregate shocks consumer type
AggShockMrkvExample = AggShockMarkovConsumerType(**Params.init_agg_mrkv_shocks)
AggShockMrkvExample = AggShockMarkovConsumerType()
AggShockMrkvExample.IncomeDstn[0] = 2*[AggShockMrkvExample.IncomeDstn[0]]
AggShockMrkvExample.cycles = 0

# Make a Cobb-Douglas economy for the agents
MrkvEconomyExample = CobbDouglasMarkovEconomy(agents=[AggShockMrkvExample], **Params.init_mrkv_cobb_douglas)
MrkvEconomyExample = CobbDouglasMarkovEconomy(agents=[AggShockMrkvExample])
MrkvEconomyExample.DampingFac = 0.2 # Turn down damping
MrkvEconomyExample.makeAggShkHist() # Simulate a history of aggregate shocks
AggShockMrkvExample.getEconomyData(
Expand Down Expand Up @@ -1934,14 +1955,14 @@ def mystr(number): return "{:.4f}".format(number)
PolyMrkvArray[StateCount-1, StateCount-1] += 0.5*(1.0 - Persistence)

# Make a consumer type to inhabit the economy
PolyStateExample = AggShockMarkovConsumerType(**Params.init_agg_mrkv_shocks)
PolyStateExample = AggShockMarkovConsumerType()
PolyStateExample.MrkvArray = PolyMrkvArray
PolyStateExample.PermGroFacAgg = PermGroFacAgg
PolyStateExample.IncomeDstn[0] = StateCount*[PolyStateExample.IncomeDstn[0]]
PolyStateExample.cycles = 0

# Make a Cobb-Douglas economy for the agents
PolyStateEconomy = CobbDouglasMarkovEconomy(agents=[PolyStateExample], **Params.init_mrkv_cobb_douglas)
PolyStateEconomy = CobbDouglasMarkovEconomy(agents=[PolyStateExample])
PolyStateEconomy.MrkvArray = PolyMrkvArray
PolyStateEconomy.PermGroFacAgg = PermGroFacAgg
PolyStateEconomy.PermShkAggStd = StateCount*[0.006]
Expand Down
1 change: 0 additions & 1 deletion HARK/ConsumptionSaving/ConsumerParameters.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@
'CRRA': CRRAPF,
'PermGroFacAgg': PermGroFacAgg,
'AggregateL':1.0,
'act_T':1200,
'intercept_prev': intercept_prev,
'slope_prev': slope_prev,
'verbose': verbose_cobb_douglas,
Expand Down

0 comments on commit ed017fa

Please sign in to comment.