ChinaExample = MarkovConsumerType(**init_China_parameters) # %% [markdown] # Currently, Markov states can differ in their interest factor, permanent growth factor, survival probability, and income distribution. Each of these needs to be specifically set. # # Do that here, except shock distribution, which will be done later (because we want to examine the consequences of different shock distributions). # %% GrowthFastAnn = 1.06 # Six percent annual growth GrowthSlowAnn = 1.00 # Stagnation ChinaExample.assignParameters(PermGroFac = [np.array([GrowthSlowAnn,GrowthFastAnn ** (.25)])], #needs to be a list, with 0th element of shape of shape (StateCount,) Rfree = np.array(StateCount*[init_China_parameters['Rfree']]), #needs to be an array, of shape (StateCount,) LivPrb = [np.array(StateCount*[init_China_parameters['LivPrb']][0])], #needs to be a list, with 0th element of shape of shape (StateCount,) cycles = 0) ChinaExample.track_vars = ['aNrmNow','cNrmNow','pLvlNow'] # Names of variables to be tracked # %% [markdown] # Now, add in ex-ante heterogeneity in consumers' discount factors. # # The cstwMPC parameters do not define a single discount factor; instead, there is ex-ante heterogeneity in the discount factor. To prepare to create this ex-ante heterogeneity, first create the desired number of consumer types: # # %% num_consumer_types = 7 # declare the number of types we want ChineseConsumerTypes = [] # initialize an empty list for nn in range(num_consumer_types): # Now create the types, and append them to the list ChineseConsumerTypes newType = deepcopy(ChinaExample) ChineseConsumerTypes.append(newType)
"Solving a Markov consumer with serially correlated unemployment took " + mystr(end_time - start_time) + " seconds." ) print("Consumption functions for each discrete state:") plotFuncs(SerialUnemploymentExample.solution[0].cFunc, 0, 50) if SerialUnemploymentExample.vFuncBool: print("Value functions for each discrete state:") plotFuncs(SerialUnemploymentExample.solution[0].vFunc, 5, 50) # %% # Simulate some data; results stored in cHist, mNrmNow_hist, cNrmNow_hist, and MrkvNow_hist if do_simulation: SerialUnemploymentExample.T_sim = 120 SerialUnemploymentExample.MrkvPrbsInit = [0.25, 0.25, 0.25, 0.25] SerialUnemploymentExample.track_vars = ["mNrmNow", "cNrmNow"] SerialUnemploymentExample.makeShockHistory() # This is optional SerialUnemploymentExample.initializeSim() SerialUnemploymentExample.simulate() # %% [markdown] # ### 2. Unemployment immunity for a fixed period # # Let's create a consumer similar to the one in "idiosyncratic shock" model but who occasionally gets "unemployment immunity" for a fixed period in an economy subject to boom and bust cycles. # %% # Make a consumer who occasionally gets "unemployment immunity" for a fixed period UnempPrb = 0.05 # Probability of becoming unemployed each period ImmunityPrb = 0.01 # Probability of becoming "immune" to unemployment ImmunityT = 6 # Number of periods of immunity