def setUp(self): # Set up and solve TBS base_primitives = {'UnempPrb' : .015, 'DiscFac' : 0.9, 'Rfree' : 1.1, 'PermGroFac' : 1.05, 'CRRA' : .95} TBSType = TractableConsumerType(**base_primitives) TBSType.solve() # Set up and solve Markov MrkvArray = np.array([[1.0-base_primitives['UnempPrb'],base_primitives['UnempPrb']], [0.0,1.0]]) Markov_primitives = {"CRRA":base_primitives['CRRA'], "Rfree":np.array(2*[base_primitives['Rfree']]), "PermGroFac":[np.array(2*[base_primitives['PermGroFac']/ (1.0-base_primitives['UnempPrb'])])], "BoroCnstArt":None, "PermShkStd":[0.0], "PermShkCount":1, "TranShkStd":[0.0], "TranShkCount":1, "T_total":1, "UnempPrb":0.0, "UnempPrbRet":0.0, "T_retire":0, "IncUnemp":0.0, "IncUnempRet":0.0, "aXtraMin":0.001, "aXtraMax":TBSType.mUpperBnd, "aXtraCount":48, "aXtraExtra":[None], "aXtraNestFac":3, "LivPrb":[1.0], "DiscFac":base_primitives['DiscFac'], 'Nagents':1, 'psi_seed':0, 'xi_seed':0, 'unemp_seed':0, 'tax_rate':0.0, 'vFuncBool':False, 'CubicBool':True, 'MrkvArray':MrkvArray } MarkovType = MarkovConsumerType(**Markov_primitives) MarkovType.cycles = 0 employed_income_dist = [np.ones(1),np.ones(1),np.ones(1)] unemployed_income_dist = [np.ones(1),np.ones(1),np.zeros(1)] MarkovType.IncomeDstn = [[employed_income_dist,unemployed_income_dist]] MarkovType.solve() MarkovType.unpackcFunc() self.TBSType = TBSType self.MarkovType = MarkovType
def setUp(self): # Set up and solve TBS base_primitives = { 'UnempPrb': .015, 'DiscFac': 0.9, 'Rfree': 1.1, 'PermGroFac': 1.05, 'CRRA': .95 } TBSType = TractableConsumerType(**base_primitives) TBSType.solve() # Set up and solve Markov MrkvArray = np.array( [[1.0 - base_primitives['UnempPrb'], base_primitives['UnempPrb']], [0.0, 1.0]]) Markov_primitives = { "CRRA": base_primitives['CRRA'], "Rfree": np.array(2 * [base_primitives['Rfree']]), "PermGroFac": [ np.array(2 * [ base_primitives['PermGroFac'] / (1.0 - base_primitives['UnempPrb']) ]) ], "BoroCnstArt": None, "PermShkStd": [0.0], "PermShkCount": 1, "TranShkStd": [0.0], "TranShkCount": 1, "T_total": 1, "UnempPrb": 0.0, "UnempPrbRet": 0.0, "T_retire": 0, "IncUnemp": 0.0, "IncUnempRet": 0.0, "aXtraMin": 0.001, "aXtraMax": TBSType.mUpperBnd, "aXtraCount": 48, "aXtraExtra": [None], "exp_nest": 3, "LivPrb": [1.0], "DiscFac": base_primitives['DiscFac'], 'Nagents': 1, 'psi_seed': 0, 'xi_seed': 0, 'unemp_seed': 0, 'tax_rate': 0.0, 'vFuncBool': False, 'CubicBool': True, 'MrkvArray': MrkvArray } MarkovType = MarkovConsumerType(**Markov_primitives) MarkovType.cycles = 0 employed_income_dist = [np.ones(1), np.ones(1), np.ones(1)] unemployed_income_dist = [np.ones(1), np.ones(1), np.zeros(1)] MarkovType.IncomeDstn = [[ employed_income_dist, unemployed_income_dist ]] MarkovType.solve() MarkovType.unpackcFunc() self.TBSType = TBSType self.MarkovType = MarkovType
InfiniteType.a_init = 0 * np.ones_like(a_init) # Make histories of permanent income levels for the infinite horizon type p_init_base = np.ones(Params.sim_pop_size, dtype=float) InfiniteType.p_init = p_init_base # Use a "tractable consumer" instead if desired. # If you want this to work, you must edit TractableBufferStockModel slightly. # See comments around line 34 in that module for instructions. if Params.do_tractable: from TractableBufferStockModel import TractableConsumerType TractableInfType = TractableConsumerType( DiscFac=0.99, # will be overwritten UnempPrb=1 - InfiniteType.LivPrb[0], Rfree=InfiniteType.Rfree, PermGroFac=InfiniteType.PermGroFac[0], CRRA=InfiniteType.CRRA, sim_periods=InfiniteType.sim_periods, IncUnemp=InfiniteType.IncUnemp, Nagents=InfiniteType.Nagents) TractableInfType.p_init = InfiniteType.p_init TractableInfType.timeFwd() TractableInfType.TranShkHist = InfiniteType.TranShkHist TractableInfType.PermShkHist = InfiniteType.PermShkHist TractableInfType.a_init = InfiniteType.a_init # Set the type list for the infinite horizon estimation if Params.do_tractable: short_type_list = [TractableInfType] spec_add = 'TC' else:
InfiniteType.tolerance = 0.0001 InfiniteType.a_init = 0*np.ones_like(a_init) # Make histories of permanent income levels for the infinite horizon type p_init_base = np.ones(Params.sim_pop_size,dtype=float) InfiniteType.p_init = p_init_base # Use a "tractable consumer" instead if desired. # If you want this to work, you must edit TractableBufferStockModel slightly. # See comments around line 34 in that module for instructions. if Params.do_tractable: from TractableBufferStockModel import TractableConsumerType TractableInfType = TractableConsumerType(DiscFac=0.99, # will be overwritten UnempPrb=1-InfiniteType.LivPrb[0], Rfree=InfiniteType.Rfree, PermGroFac=InfiniteType.PermGroFac[0], CRRA=InfiniteType.CRRA, sim_periods=InfiniteType.sim_periods, IncUnemp=InfiniteType.IncUnemp, Nagents=InfiniteType.Nagents) TractableInfType.p_init = InfiniteType.p_init TractableInfType.timeFwd() TractableInfType.TranShkHist = InfiniteType.TranShkHist TractableInfType.PermShkHist = InfiniteType.PermShkHist TractableInfType.a_init = InfiniteType.a_init # Set the type list for the infinite horizon estimation if Params.do_tractable: short_type_list = [TractableInfType] spec_add = 'TC' else: short_type_list = [InfiniteType]