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: HARK.ConsumptionSaving.ConsIndShockModel.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.

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.
Returns:
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
Returns:
Return type:None
get_MaggNow()
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_controls()

Calculates consumption for each consumer of this type using the consumption functions.

Parameters:None
Returns:
Return type:None
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.
Returns:
Return type:None
get_shocks()

Finds the effective permanent and transitory shocks this period by combining the aggregate and idiosyncratic shocks of each type.

Parameters:None
Returns:
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.
Returns:

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.

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
Returns:
Return type:None
pre_solve()

A method that is run immediately before the model is solved, to check inputs or to prepare the terminal solution, perhaps.

Parameters:none
Returns:
Return type:none
reset()

Initialize this type for a new simulated history of K/L ratio.

Parameters:None
Returns:
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”.
Returns:
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)
update_solution_terminal()

Updates the terminal period solution for an aggregate shock consumer. Only fills in the consumption function and marginal value function.

Parameters:None
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsAggShockModel.AggShockMarkovConsumerType(**kwds)

Bases: HARK.ConsumptionSaving.ConsAggShockModel.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.

getMrkvNow()
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
Returns:
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
Returns:
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
Returns:
Return type:None
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
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasEconomy(agents=None, tolerance=0.0001, act_T=1200, **kwds)

Bases: HARK.core.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.
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.

Parameters:
  • MaggNow ([float]) – List of the history of the simulated aggregate market resources for an economy.
  • AaggNow ([float]) – List of the history of the simulated aggregate savings for an economy.
Returns:

(unnamed) – Object containing a new savings rule

Return type:

CapDynamicRule

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_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.

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:float
make_AggShkDstn()

Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount.

Parameters:None
Returns:
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
Returns:
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().

See documentation for calc_R_and_W for more information.

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
Returns:
Return type:None
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
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenEconomy(agents=None, tolerance=0.0001, act_T=1000, **kwds)

Bases: HARK.core.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.
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.

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.
make_AggShkDstn()

Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount.

Parameters:None
Returns:
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
Returns:
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.

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
Returns:
Return type:None
update()

Use primitive parameters to set basic objects. This is an extremely stripped-down version of update for CobbDouglasEconomy.

Parameters:none
Returns:
Return type:none
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: HARK.ConsumptionSaving.ConsAggShockModel.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.
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:
  • MaggNow ([float]) – List of the history of the simulated aggregate market resources for an economy.
  • AaggNow ([float]) – List of the history of the simulated aggregate savings for an economy.
Returns:

(unnamed) – Object containing new saving rules for each Markov state.

Return type:

CapDynamicRule

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:float
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
Returns:
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
Returns:
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
Returns:
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.

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.
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
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenMarkovEconomy(agents=None, tolerance=0.0001, act_T=1000, **kwds)

Bases: HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasMarkovEconomy, HARK.ConsumptionSaving.ConsAggShockModel.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.

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_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
Returns:
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
Returns:
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.

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.
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
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsAggShockModel.AggregateSavingRule(intercept, slope)

Bases: HARK.core.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).

Parameters:
  • intercept (float) – Intercept of the log-linear capital evolution rule.
  • slope (float) – Slope of the log-linear capital evolution rule.
class HARK.ConsumptionSaving.ConsAggShockModel.AggShocksDynamicRule(AFunc)

Bases: HARK.core.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.