# HARK.ConsumptionSaving.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(time_flow=True, **kwds)

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.

addAggShkDstn(AggShkDstn)

Updates attribute IncomeDstn 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. None
calcBoundingValues()

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 – None
getControls()

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

Parameters: None – None
getEconomyData(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. None
getRfree()

Returns an array of size self.AgentCount with self.RfreeNow in every entry.

Parameters: None – RfreeNow – Array of size self.AgentCount with risk free interest rate for each agent. np.array
getShocks()

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

Parameters: None – None
makeEulerErrorFunc(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.IncomeDstn 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.IncomeDstn[0], or to use a very accurate discrete approximation instead. When True, uses approximation in IncomeDstn; when False, makes and uses a very dense approximation. None
marketAction()

In the aggregate shocks model, the “market action” is to simulate one period of receiving income and choosing how much to consume.

Parameters: None – None
reset()

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

Parameters: None – None
simBirth(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”. None
simDeath()

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 – who_dies – Boolean array of size AgentCount indicating which agents die. np.array(bool)
updateSolutionTerminal()

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

Parameters: None – None
class HARK.ConsumptionSaving.ConsAggShockModel.AggShockMarkovConsumerType(**kwds)

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.

addAggShkDstn(AggShkDstn)

Variation on AggShockConsumerType.addAggShkDstn that handles the Markov state. AggShkDstn is a list of aggregate productivity shock distributions for each Markov state.

getControls()

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 – None
getShocks()

Gets permanent and transitory income shocks for this period. Samples from IncomeDstn for each period in the cycle. This is a copy-paste from IndShockConsumerType, with the addition of the Markov macroeconomic state. Unfortunately, the getShocks 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 – None
updateSolutionTerminal()

Update the terminal period solution. This method should be run when a new AgentType is created or when CRRA changes.

Parameters: None – None
class HARK.ConsumptionSaving.ConsAggShockModel.AggShocksDynamicRule(AFunc)

Just a container class for passing the dynamic rule in the aggregate shocks model to agents.

class HARK.ConsumptionSaving.ConsAggShockModel.AggregateSavingRule(intercept, slope)

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.CobbDouglasAggVars(MaggNow, AaggNow, KtoLnow, RfreeNow, wRteNow, PermShkAggNow, TranShkAggNow)

A simple class for holding the relevant aggregate variables that should be passed from the market to each type. Includes the capital-to-labor ratio, the interest factor, the wage rate, and the aggregate permanent and tran- sitory shocks.

class HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasEconomy(agents=[], tolerance=0.0001, act_T=1200, **kwds)

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.

calcAFunc(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. (unnamed) – Object containing a new savings rule CapDynamicRule
calcDynamics(MaggNow, AaggNow)

Calculates a new dynamic rule for the economy: end of period savings as a function of aggregate market resources. Just calls calcAFunc().

calcRandW(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. AggVarsNow – An object containing the aggregate variables for the upcoming period: capital-to-labor ratio, interest factor, (normalized) wage rate, aggregate permanent and transitory shocks. CobbDouglasAggVars
getPermGroFacAggLR()

A trivial function that returns self.PermGroFacAgg. Exists to be overwritten and extended by ConsAggShockMarkov model.

Parameters: None – PermGroFacAggLR – Long run aggregate permanent income growth, which is the same thing as aggregate permanent income growth. float
makeAggShkDstn()

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

Parameters: None – None
makeAggShkHist()

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 – None
millRule(aLvlNow, pLvlNow)

Function to calculate the capital to labor ratio, interest factor, and wage rate based on each agent’s current state. Just calls calcRandW().

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 – 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 – None
class HARK.ConsumptionSaving.ConsAggShockModel.CobbDouglasMarkovEconomy(agents=[], tolerance=0.0001, act_T=1200, **kwds)

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.

calcAFunc(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. (unnamed) – Object containing new saving rules for each Markov state. CapDynamicRule
getPermGroFacAggLR()

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 – PermGroFacAggLR – Long run aggregate permanent income growth factor float
makeAggShkDstn()

Creates the attributes TranShkAggDstn, PermShkAggDstn, and AggShkDstn. Draws on attributes TranShkAggStd, PermShkAddStd, TranShkAggCount, PermShkAggCount. This version accounts for the Markov macroeconomic state.

Parameters: None – None
makeAggShkHist()

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

Parameters: None – None
makeMrkvHist()

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 calcDynamics to produce a good dynamic rule. It will sometimes cause act_T to be increased beyond its initially specified level.

Parameters: None – None
millRule(aLvlNow, pLvlNow)

Function to calculate the capital to labor ratio, interest factor, and wage rate based on each agent’s current state. Just calls calcRandW() and adds the Markov state index.

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 – None
class HARK.ConsumptionSaving.ConsAggShockModel.MargValueFunc2D(cFunc, CRRA)

A class for representing a marginal value function in models where the standard envelope condition of dvdm(m,M) = u’(c(m,M)) holds (with CRRA utility).

class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenEconomy(agents=[], tolerance=0.0001, act_T=1000, **kwds)

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.

calcDynamics(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.

getAggShocks()

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 – AggVarsNow – Aggregate state and shock variables for this period. CobbDouglasAggVars
makeAggShkDstn()

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

Parameters: None – None
makeAggShkHist()

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 – None
millRule()

No aggregation occurs for a small open economy, because the wage and interest rates are exogenously determined. However, aggregate shocks may occur.

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 – None
update()

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

Parameters: none – none
class HARK.ConsumptionSaving.ConsAggShockModel.SmallOpenMarkovEconomy(agents=[], tolerance=0.0001, act_T=1000, **kwds)

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.

HARK.ConsumptionSaving.ConsAggShockModel.solveConsAggMarkov(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, MrkvArray, PermGroFac, PermGroFacAgg, aXtraGrid, BoroCnstArt, Mgrid, AFunc, Rfunc, wFunc, DeprFac)

Solve one period of a consumption-saving problem with idiosyncratic and aggregate shocks (transitory and permanent). Moreover, the macroeconomic state follows a Markov process that determines the income distribution and aggregate permanent growth factor. This is a basic solver that can’t handle cubic splines, nor can it calculate a value function.

Parameters: solution_next (ConsumerSolution) – The solution to the succeeding one period problem. IncomeDstn ([[np.array]]) – A list of lists, each containing five arrays of floats, representing a discrete approximation to the income process between the period being solved and the one immediately following (in solution_next). Order: event probabilities, idisyncratic permanent shocks, idiosyncratic transitory shocks, aggregate permanent shocks, aggregate transitory shocks. LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period. DiscFac (float) – Intertemporal discount factor for future utility. CRRA (float) – Coefficient of relative risk aversion. MrkvArray (np.array) – Markov transition matrix between discrete macroeconomic states. MrkvArray[i,j] is probability of being in state j next period conditional on being in state i this period. PermGroFac (float) – Expected permanent income growth factor at the end of this period, for the individual’s productivity. PermGroFacAgg ([float]) – Expected aggregate productivity growth in each Markov macro state. aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level. BoroCnstArt (float) – Artificial borrowing constraint; minimum allowable end-of-period asset-to- permanent-income ratio. Unlike other models, this can’t be None. Mgrid (np.array) – A grid of aggregate market resourses to permanent income in the economy. AFunc ([function]) – Aggregate savings as a function of aggregate market resources, for each Markov macro state. Rfunc (function) – The net interest factor on assets as a function of capital ratio k. wFunc (function) – The wage rate for labor as a function of capital-to-labor ratio k. DeprFac (float) – Capital Depreciation Rate solution_now – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (linear interpolation over linear interpola- tions) and marginal value function vPfunc. ConsumerSolution
HARK.ConsumptionSaving.ConsAggShockModel.solveConsAggShock(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, PermGroFac, PermGroFacAgg, aXtraGrid, BoroCnstArt, Mgrid, AFunc, Rfunc, wFunc, DeprFac)

Solve one period of a consumption-saving problem with idiosyncratic and aggregate shocks (transitory and permanent). This is a basic solver that can’t handle cubic splines, nor can it calculate a value function.

Parameters: solution_next (ConsumerSolution) – The solution to the succeeding one period problem. IncomeDstn ([np.array]) – A list containing five arrays of floats, representing a discrete approximation to the income process between the period being solved and the one immediately following (in solution_next). Order: event probabilities, idisyncratic permanent shocks, idiosyncratic transitory shocks, aggregate permanent shocks, aggregate transitory shocks. LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period. DiscFac (float) – Intertemporal discount factor for future utility. CRRA (float) – Coefficient of relative risk aversion. PermGroFac (float) – Expected permanent income growth factor at the end of this period. PermGroFacAgg (float) – Expected aggregate productivity growth factor. aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level. BoroCnstArt (float) – Artificial borrowing constraint; minimum allowable end-of-period asset-to- permanent-income ratio. Unlike other models, this can’t be None. Mgrid (np.array) – A grid of aggregate market resourses to permanent income in the economy. AFunc (function) – Aggregate savings as a function of aggregate market resources. Rfunc (function) – The net interest factor on assets as a function of capital ratio k. wFunc (function) – The wage rate for labor as a function of capital-to-labor ratio k. DeprFac (float) – Capital Depreciation Rate solution_now – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (linear interpolation over linear interpola- tions) and marginal value function vPfunc. ConsumerSolution