def main_test(self): Markov_vFuncBool_example = MarkovConsumerType(**Markov_Dict) TranShkDstn_e = MeanOneLogNormal( Markov_vFuncBool_example.TranShkStd[0], 123).approx(Markov_vFuncBool_example.TranShkCount) TranShkDstn_u = DiscreteDistribution(np.ones(1), np.ones(1) * .2) PermShkDstn = MeanOneLogNormal( Markov_vFuncBool_example.PermShkStd[0], 123).approx(Markov_vFuncBool_example.PermShkCount) #employed Income shock distribution employed_IncShkDstn = combine_indep_dstns(PermShkDstn, TranShkDstn_e) #unemployed Income shock distribution unemployed_IncShkDstn = combine_indep_dstns(PermShkDstn, TranShkDstn_u) # Specify list of IncShkDstns for each state Markov_vFuncBool_example.IncShkDstn = [[ employed_IncShkDstn, unemployed_IncShkDstn ]] #solve the consumer's problem Markov_vFuncBool_example.solve() self.assertAlmostEqual( Markov_vFuncBool_example.solution[0].vFunc[1](0.4), -4.127935542867632)
def setUp(self): # Set up and solve TBS base_primitives = { "UnempPrb": 0.015, "DiscFac": 0.9, "Rfree": 1.1, "PermGroFac": 1.05, "CRRA": 0.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": [ np.array([1.0, 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, "T_cycle": 1, } MarkovType = MarkovConsumerType(**Markov_primitives) MarkovType.cycles = 0 employed_income_dist = DiscreteDistribution(np.ones(1), np.array([[1.0], [1.0]])) unemployed_income_dist = DiscreteDistribution(np.ones(1), np.array([[1.0], [0.0]])) MarkovType.IncShkDstn = [[ employed_income_dist, unemployed_income_dist ]] MarkovType.solve() MarkovType.unpack("cFunc") self.TBSType = TBSType self.MarkovType = MarkovType