def getEconomyData(self, Economy): ''' Imports economy-determined objects into self from a Market. Instances of AggShockConsumerType "live" in some macroeconomy that has attributes relevant to their microeconomic model, like the relationship between the capital-to-labor ratio and the interest and wage rates; this method imports those attributes from an "economy" object and makes them attributes of the ConsumerType. Parameters ---------- Economy : Market The "macroeconomy" in which this instance "lives". Might be of the subclass CobbDouglasEconomy, which has methods to generate the relevant attributes. Returns ------- None ''' AggShockConsumerType.getEconomyData(self, Economy) self.KtoLBeliefNow_init = Economy.KtoLnow_init * np.ones(self.Nagents)
# Now do aggregate shocks of a market # Make an aggregate shocks consumer AggShockExample = AggShockConsumerType(**Params.init_agg_shocks) AggShockExample.cycles = 0 AggShockExample.sim_periods = 3000 AggShockExample.makeIncShkHist( ) # Simulate a history of idiosyncratic shocks # Make a Cobb-Douglas economy for the agents EconomyExample = CobbDouglasEconomy(agents=[AggShockExample], act_T=AggShockExample.sim_periods, **Params.init_cobb_douglas) EconomyExample.makeAggShkHist() # Simulate a history of aggregate shocks # Have the consumers inherit relevant objects from the economy AggShockExample.getEconomyData(EconomyExample) # Solve the microeconomic model for the aggregate shocks example type (and display results) t_start = clock() AggShockExample.solve() t_end = clock() print('Solving an aggregate shocks consumer took ' + mystr(t_end - t_start) + ' seconds.') # # Solve the "macroeconomic" model by searching for a "fixed point dynamic rule" # t_start = clock() # EconomyExample.solve() # t_end = clock() # print('Solving the "macroeconomic" aggregate shocks model took ' + str(t_end - t_start) + ' seconds.') PermShk = 1.1
# Make a Cobb-Douglas economy for the agents StickyEconomyExample = CobbDouglasEconomy(agents=[StickyExample], act_T=StickyExample.sim_periods, **Params.init_cobb_douglas) NotStickyEconomyExample = CobbDouglasEconomy( agents=[NotStickyExample], act_T=NotStickyExample.sim_periods, **Params.init_cobb_douglas) StickyEconomyExample.makeAggShkHist( ) # Simulate a history of aggregate shocks NotStickyEconomyExample.makeAggShkHist( ) # Simulate a history of aggregate shocks # Have the consumers inherit relevant objects from the economy StickyExample.getEconomyData(StickyEconomyExample) NotStickyExample.getEconomyData(NotStickyEconomyExample) # Solve the microeconomic model for the aggregate shocks example type (and display results) t_start = clock() StickyExample.solve() NotStickyExample.solve() t_end = clock() print('Solving an aggregate shocks consumer took ' + mystr(t_end - t_start) + ' seconds.') # # Solve the "macroeconomic" model by searching for a "fixed point dynamic rule" # t_start = clock() # StickyEconomyExample.solve() # NotStickyEconomyExample.solve() # t_end = clock() # print('Solving the "macroeconomic" aggregate shocks model took ' + str(t_end - t_start) + ' seconds.')