ConsAggShockModel#
Consumption-saving models with aggregate productivity shocks as well as idiosyn- cratic income shocks. Currently only contains one microeconomic model with a basic solver. Also includes a subclass of Market called CobbDouglas economy, used for solving “macroeconomic” models with aggregate shocks.
- class HARK.ConsumptionSaving.ConsAggShockModel.AggShockConsumerType(**kwds)#
Bases:
IndShockConsumerType
A class to represent consumers who face idiosyncratic (transitory and per- manent) shocks to their income and live in an economy that has aggregate (transitory and permanent) shocks to labor productivity. As the capital- to-labor ratio varies in the economy, so does the wage rate and interest rate. “Aggregate shock consumers” have beliefs about how the capital ratio evolves over time and take aggregate shocks into account when making their decision about how much to consume.
- reset()#
Initialize this type for a new simulated history of K/L ratio.
- Parameters:
None
- Return type:
None
- pre_solve()#
Method that is run automatically just before solution by backward iteration. Solves the (trivial) terminal period and does a quick check on the borrowing constraint and MaxKinks attribute (only relevant in constrained, infinite horizon problems).
- get_economy_data(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.
- Return type:
None
- add_AggShkDstn(AggShkDstn)#
Updates attribute IncShkDstn by combining idiosyncratic shocks with aggregate shocks.
- Parameters:
AggShkDstn ([np.array]) – Aggregate productivity shock distribution. First element is proba- bilities, second element is agg permanent shocks, third element is agg transitory shocks.
- Return type:
None
- sim_birth(which_agents)#
Makes new consumers for the given indices. Initialized variables include aNrm and pLvl, as well as time variables t_age and t_cycle. Normalized assets and permanent income levels are drawn from lognormal distributions given by aNrmInitMean and aNrmInitStd (etc).
- Parameters:
which_agents (np.array(Bool)) – Boolean array of size self.AgentCount indicating which agents should be “born”.
- Return type:
None
- sim_death()#
Randomly determine which consumers die, and distribute their wealth among the survivors. This method only works if there is only one period in the cycle.
- Parameters:
None
- Returns:
who_dies – Boolean array of size AgentCount indicating which agents die.
- Return type:
np.array(bool)
- get_Rfree()#
Returns an array of size self.AgentCount with self.RfreeNow in every entry.
- Parameters:
None
- Returns:
RfreeNow – Array of size self.AgentCount with risk free interest rate for each agent.
- Return type:
np.array
- get_shocks()#
Finds the effective permanent and transitory shocks this period by combining the aggregate and idiosyncratic shocks of each type.
- Parameters:
None
- Return type:
None
- get_controls()#
Calculates consumption for each consumer of this type using the consumption functions.
- Parameters:
None
- Return type:
None
- get_MaggNow()#
- market_action()#
In the aggregate shocks model, the “market action” is to simulate one period of receiving income and choosing how much to consume.
- Parameters:
None
- Return type:
None
- calc_bounding_values()#
Calculate human wealth plus minimum and maximum MPC in an infinite horizon model with only one period repeated indefinitely. Store results as attributes of self. Human wealth is the present discounted value of expected future income after receiving income this period, ignoring mort- ality. The maximum MPC is the limit of the MPC as m –> mNrmMin. The minimum MPC is the limit of the MPC as m –> infty.
NOT YET IMPLEMENTED FOR THIS CLASS
- Parameters:
None
- Return type:
None
- make_euler_error_func(mMax=100, approx_inc_dstn=True)#
Creates a “normalized Euler error” function for this instance, mapping from market resources to “consumption error per dollar of consumption.” Stores result in attribute eulerErrorFunc as an interpolated function. Has option to use approximate income distribution stored in self.IncShkDstn or to use a (temporary) very dense approximation.
NOT YET IMPLEMENTED FOR THIS CLASS
- Parameters:
mMax (float) – Maximum normalized market resources for the Euler error function.
approx_inc_dstn (Boolean) – Indicator for whether to use the approximate discrete income distri- bution stored in self.IncShkDstn[0], or to use a very accurate discrete approximation instead. When True, uses approximation in IncShkDstn; when False, makes and uses a very dense approximation.
- Return type:
None
Notes
This method is not used by any other code in the library. Rather, it is here for expository and benchmarking purposes.
- class HARK.ConsumptionSaving.ConsAggShockModel.AggShockMarkovConsumerType(**kwds)#
Bases:
AggShockConsumerType
A class for representing ex ante heterogeneous “types” of consumers who experience both aggregate and idiosyncratic shocks to productivity (both permanent and transitory), who lives in an environment where the macroeconomic state is subject to Markov-style discrete state evolution.
- add_AggShkDstn(AggShkDstn)#
Variation on AggShockConsumerType.add_AggShkDstn that handles the Markov state. AggShkDstn is a list of aggregate productivity shock distributions for each Markov state.
- update_solution_terminal()#
Update the terminal period solution. This method should be run when a new AgentType is created or when CRRA changes.
- Parameters:
None
- Return type:
None
- reset_rng()#
Reset the RNG behavior of this type. This method is called automatically by initialize_sim(), ensuring that each simulation run uses the same sequence of random shocks; this is necessary for structural estimation to work. This method extends AgentType.reset_rng() to also reset elements of IncShkDstn.
- Parameters:
None
- Return type:
None
- get_shocks()#
Gets permanent and transitory income shocks for this period. Samples from IncShkDstn for each period in the cycle. This is a copy-paste from IndShockConsumerType, with the addition of the Markov macroeconomic state. Unfortunately, the get_shocks method for MarkovConsumerType cannot be used, as that method assumes that MrkvNow is a vector with a value for each agent, not just a single int.
- Parameters:
None
- Return type:
None
- get_controls()#
Calculates consumption for each consumer of this type using the consumption functions. For this AgentType class, MrkvNow is the same for all consumers. However, in an extension with “macroeconomic inattention”, consumers might misperceive the state and thus act as if they are in different states.
- Parameters:
None
- Return type:
None
- getMrkvNow()#
- class HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasEconomy(agents=None, tolerance=0.0001, act_T=1200, **kwds)#
Bases:
Market
A class to represent an economy with a Cobb-Douglas aggregate production function over labor and capital, extending HARK.Market. The “aggregate market process” for this market combines all individuals’ asset holdings into aggregate capital, yielding the interest factor on assets and the wage rate for the upcoming period.
Note: The current implementation assumes a constant labor supply, but this will be generalized in the future.
- Parameters:
agents ([ConsumerType]) – List of types of consumers that live in this economy.
tolerance (float) – Minimum acceptable distance between “dynamic rules” to consider the solution process converged. Distance depends on intercept and slope of the log-linear “next capital ratio” function.
act_T (int) – Number of periods to simulate when making a history of of the market.
- mill_rule(aLvl, pLvl)#
Function to calculate the capital to labor ratio, interest factor, and wage rate based on each agent’s current state. Just calls calc_R_and_W().
See documentation for calc_R_and_W for more information.
- calc_dynamics(MaggNow, AaggNow)#
Calculates a new dynamic rule for the economy: end of period savings as a function of aggregate market resources. Just calls calc_AFunc().
See documentation for calc_AFunc for more information.
- update()#
Use primitive parameters (and perfect foresight calibrations) to make interest factor and wage rate functions (of capital to labor ratio), as well as discrete approximations to the aggregate shock distributions.
- Parameters:
None
- Return type:
None
- get_PermGroFacAggLR()#
A trivial function that returns self.PermGroFacAgg. Exists to be overwritten and extended by ConsAggShockMarkov model.
- Parameters:
None
- Returns:
PermGroFacAggLR – Long run aggregate permanent income growth, which is the same thing as aggregate permanent income growth.
- Return type:
- make_AggShkDstn()#
Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount.
- Parameters:
None
- Return type:
None
- reset()#
Reset the economy to prepare for a new simulation. Sets the time index of aggregate shocks to zero and runs Market.reset().
- Parameters:
None
- Return type:
None
- make_AggShkHist()#
Make simulated histories of aggregate transitory and permanent shocks. Histories are of length self.act_T, for use in the general equilibrium simulation.
- Parameters:
None
- Return type:
None
- calc_R_and_W(aLvlNow, pLvlNow)#
Calculates the interest factor and wage rate this period using each agent’s capital stock to get the aggregate capital ratio.
- Parameters:
aLvlNow ([np.array]) – Agents’ current end-of-period assets. Elements of the list correspond to types in the economy, entries within arrays to agents of that type.
- Returns:
MaggNow (float) – Aggregate market resources for this period normalized by mean permanent income
AaggNow (float) – Aggregate savings for this period normalized by mean permanent income
RfreeNow (float) – Interest factor on assets in the economy this period.
wRteNow (float) – Wage rate for labor in the economy this period.
PermShkAggNow (float) – Permanent shock to aggregate labor productivity this period.
TranShkAggNow (float) – Transitory shock to aggregate labor productivity this period.
KtoLnow (float) – Capital-to-labor ratio in the economy this period.
- calc_AFunc(MaggNow, AaggNow)#
Calculate a new aggregate savings rule based on the history of the aggregate savings and aggregate market resources from a simulation.
- class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenEconomy(agents=None, tolerance=0.0001, act_T=1000, **kwds)#
Bases:
Market
A class for representing a small open economy, where the wage rate and interest rate are exogenously determined by some “global” rate. However, the economy is still subject to aggregate productivity shocks.
- Parameters:
agents ([ConsumerType]) – List of types of consumers that live in this economy.
tolerance (float) – Minimum acceptable distance between “dynamic rules” to consider the solution process converged. Distance depends on intercept and slope of the log-linear “next capital ratio” function.
act_T (int) – Number of periods to simulate when making a history of of the market.
- update()#
Use primitive parameters to set basic objects. This is an extremely stripped-down version of update for CobbDouglasEconomy.
- Parameters:
none
- Return type:
none
- make_AggShkDstn()#
Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount.
- Parameters:
None
- Return type:
None
- mill_rule()#
No aggregation occurs for a small open economy, because the wage and interest rates are exogenously determined. However, aggregate shocks may occur.
See documentation for get_AggShocks() for more information.
- calc_dynamics(KtoLnow)#
Calculates a new dynamic rule for the economy, which is just an empty object. There is no “dynamic rule” for a small open economy, because K/L does not generate w and R.
- reset()#
Reset the economy to prepare for a new simulation. Sets the time index of aggregate shocks to zero and runs Market.reset(). This replicates the reset method for CobbDouglasEconomy; future version should create parent class of that class and this one.
- Parameters:
None
- Return type:
None
- make_AggShkHist()#
Make simulated histories of aggregate transitory and permanent shocks. Histories are of length self.act_T, for use in the general equilibrium simulation. This replicates the same method for CobbDouglasEconomy; future version should create parent class.
- Parameters:
None
- Return type:
None
- get_AggShocks()#
Returns aggregate state variables and shocks for this period. The capital-to-labor ratio is irrelevant and thus treated as constant, and the wage and interest rates are also constant. However, aggregate shocks are assigned from a prespecified history.
- Parameters:
None
- Returns:
MaggNow (float) – Aggregate market resources for this period normalized by mean permanent income
AaggNow (float) – Aggregate savings for this period normalized by mean permanent income
RfreeNow (float) – Interest factor on assets in the economy this period.
wRteNow (float) – Wage rate for labor in the economy this period.
PermShkAggNow (float) – Permanent shock to aggregate labor productivity this period.
TranShkAggNow (float) – Transitory shock to aggregate labor productivity this period.
KtoLnow (float) – Capital-to-labor ratio in the economy this period.
- class HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasMarkovEconomy(agents=None, tolerance=0.0001, act_T=1200, sow_vars=['MaggNow', 'AaggNow', 'RfreeNow', 'wRteNow', 'PermShkAggNow', 'TranShkAggNow', 'KtoLnow', 'Mrkv'], **kwds)#
Bases:
CobbDouglasEconomy
A class to represent an economy with a Cobb-Douglas aggregate production function over labor and capital, extending HARK.Market. The “aggregate market process” for this market combines all individuals’ asset holdings into aggregate capital, yielding the interest factor on assets and the wage rate for the upcoming period. This small extension incorporates a Markov state for the “macroeconomy”, so that the shock distribution and aggregate productivity growth factor can vary over time.
- Parameters:
agents ([ConsumerType]) – List of types of consumers that live in this economy.
tolerance (float) – Minimum acceptable distance between “dynamic rules” to consider the solution process converged. Distance depends on intercept and slope of the log-linear “next capital ratio” function.
act_T (int) – Number of periods to simulate when making a history of of the market.
- update()#
Use primitive parameters (and perfect foresight calibrations) to make interest factor and wage rate functions (of capital to labor ratio), as well as discrete approximations to the aggregate shock distributions.
- Parameters:
None
- Return type:
None
- get_PermGroFacAggLR()#
Calculates and returns the long run permanent income growth factor. This is the average growth factor in self.PermGroFacAgg, weighted by the long run distribution of Markov states (as determined by self.MrkvArray).
- Parameters:
None
- Returns:
PermGroFacAggLR – Long run aggregate permanent income growth factor
- Return type:
- make_AggShkDstn()#
Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount. This version accounts for the Markov macroeconomic state.
- Parameters:
None
- Return type:
None
- make_AggShkHist()#
Make simulated histories of aggregate transitory and permanent shocks. Histories are of length self.act_T, for use in the general equilibrium simulation. Draws on history of aggregate Markov states generated by internal call to make_Mrkv_history().
- Parameters:
None
- Return type:
None
- make_Mrkv_history()#
Makes a history of macroeconomic Markov states, stored in the attribute MrkvNow_hist. This version ensures that each state is reached a sufficient number of times to have a valid sample for calc_dynamics to produce a good dynamic rule. It will sometimes cause act_T to be increased beyond its initially specified level.
- Parameters:
None
- Return type:
None
- mill_rule(aLvl, pLvl)#
Function to calculate the capital to labor ratio, interest factor, and wage rate based on each agent’s current state. Just calls calc_R_and_W() and adds the Markov state index.
See documentation for calc_R_and_W for more information.
Params#
aLvl : float pLvl : float
- returns:
Mnow (float) – Aggregate market resources for this period.
Aprev (float) – Aggregate savings for the prior period.
KtoLnow (float) – Capital-to-labor ratio in the economy this period.
Rnow (float) – Interest factor on assets in the economy this period.
Wnow (float) – Wage rate for labor in the economy this period.
MrkvNow (int) – Binary indicator for bad (0) or good (1) macroeconomic state.
- calc_AFunc(MaggNow, AaggNow)#
Calculate a new aggregate savings rule based on the history of the aggregate savings and aggregate market resources from a simulation. Calculates an aggregate saving rule for each macroeconomic Markov state.
- Parameters:
- Returns:
(unnamed) – Object containing new saving rules for each Markov state.
- Return type:
CapDynamicRule
- class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenMarkovEconomy(agents=None, tolerance=0.0001, act_T=1000, **kwds)#
Bases:
CobbDouglasMarkovEconomy
,SmallOpenEconomy
A class for representing a small open economy, where the wage rate and interest rate are exogenously determined by some “global” rate. However, the economy is still subject to aggregate productivity shocks. This version supports a discrete Markov state. All methods in this class inherit from the two parent classes.
- update()#
Use primitive parameters (and perfect foresight calibrations) to make interest factor and wage rate functions (of capital to labor ratio), as well as discrete approximations to the aggregate shock distributions.
- Parameters:
None
- Return type:
None
- make_AggShkDstn()#
Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount. This version accounts for the Markov macroeconomic state.
- Parameters:
None
- Return type:
None
- mill_rule()#
Function to calculate the capital to labor ratio, interest factor, and wage rate based on each agent’s current state. Just calls calc_R_and_W() and adds the Markov state index.
See documentation for calc_R_and_W for more information.
Params#
aLvl : float pLvl : float
- returns:
Mnow (float) – Aggregate market resources for this period.
Aprev (float) – Aggregate savings for the prior period.
KtoLnow (float) – Capital-to-labor ratio in the economy this period.
Rnow (float) – Interest factor on assets in the economy this period.
Wnow (float) – Wage rate for labor in the economy this period.
MrkvNow (int) – Binary indicator for bad (0) or good (1) macroeconomic state.
- calc_dynamics(KtoLnow)#
Calculates a new dynamic rule for the economy: end of period savings as a function of aggregate market resources. Just calls calc_AFunc().
See documentation for calc_AFunc for more information.
- make_AggShkHist()#
Make simulated histories of aggregate transitory and permanent shocks. Histories are of length self.act_T, for use in the general equilibrium simulation. Draws on history of aggregate Markov states generated by internal call to make_Mrkv_history().
- Parameters:
None
- Return type:
None
- class HARK.ConsumptionSaving.ConsAggShockModel.AggregateSavingRule(intercept, slope)#
Bases:
MetricObject
A class to represent agent beliefs about aggregate saving at the end of this period (AaggNow) as a function of (normalized) aggregate market resources at the beginning of the period (MaggNow).
- class HARK.ConsumptionSaving.ConsAggShockModel.AggShocksDynamicRule(AFunc)#
Bases:
MetricObject
Just a container class for passing the dynamic rule in the aggregate shocks model to agents.
- Parameters:
AFunc (CapitalEvoRule) – Aggregate savings as a function of aggregate market resources.