HARK.ConsumptionSaving.ConsIndShockModel

Classes to solve canonical consumption-savings models with idiosyncratic shocks to income. All models here assume CRRA utility with geometric discounting, no bequest motive, and income shocks are fully transitory or fully permanent.

It currently solves three types of models:
  1. A very basic “perfect foresight” consumption-savings model with no uncertainty.
  2. A consumption-savings model with risk over transitory and permanent income shocks.
  3. The model described in (2), with an interest rate for debt that differs from the interest rate for savings.

See NARK for information on variable naming conventions. See HARK documentation for mathematical descriptions of the models being solved.

class HARK.ConsumptionSaving.ConsIndShockModel.ConsIndShockSetup(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

A superclass for solvers of one period consumption-saving problems with constant relative risk aversion utility and permanent and transitory shocks to income. Has methods to set up but not solve the one period problem.

assignParameters(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

Assigns period parameters as attributes of self for use by other methods

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn ([np.array]) – A list containing three 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, permanent shocks, 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.
  • Rfree (float) – Risk free interest factor on end-of-period assets.
  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.
  • BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
  • aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level.
  • vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.
  • CubicBool (boolean) – An indicator for whether the solver should use cubic or linear inter- polation.
Returns:

Return type:

none

defBoroCnst(BoroCnstArt)

Defines the constrained portion of the consumption function as cFuncNowCnst, an attribute of self. Uses the artificial and natural borrowing constraints.

Parameters:BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
Returns:
Return type:none
defUtilityFuncs()

Defines CRRA utility function for this period (and its derivatives, and their inverses), saving them as attributes of self for other methods to use.

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

Perform preparatory work before calculating the unconstrained consumption function.

Parameters:none
Returns:
Return type:none
setAndUpdateValues(solution_next, IncomeDstn, LivPrb, DiscFac)

Unpacks some of the inputs (and calculates simple objects based on them), storing the results in self for use by other methods. These include: income shocks and probabilities, next period’s marginal value function (etc), the probability of getting the worst income shock next period, the patience factor, human wealth, and the bounding MPCs.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn ([np.array]) – A list containing three 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, permanent shocks, 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.
Returns:

Return type:

None

class HARK.ConsumptionSaving.ConsIndShockModel.ConsIndShockSolver(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

This class solves a single period of a standard consumption-saving problem. It inherits from ConsIndShockSolverBasic, adding the ability to perform cubic interpolation and to calculate the value function.

addvFunc(solution, EndOfPrdvP)

Creates the value function for this period and adds it to the solution.

Parameters:
  • solution (ConsumerSolution) – The solution to this single period problem, likely including the consumption function, marginal value function, etc.
  • EndOfPrdvP (np.array) – Array of end-of-period marginal value of assets corresponding to the asset values in self.aNrmNow.
Returns:

solution – The single period solution passed as an input, but now with the value function (defined over market resources m) as an attribute.

Return type:

ConsumerSolution

addvPPfunc(solution)

Adds the marginal marginal value function to an existing solution, so that the next solver can evaluate vPP and thus use cubic interpolation.

Parameters:solution (ConsumerSolution) – The solution to this single period problem, which must include the consumption function.
Returns:solution – The same solution passed as input, but with the marginal marginal value function for this period added as the attribute vPPfunc.
Return type:ConsumerSolution
makeCubiccFunc(mNrm, cNrm)

Makes a cubic spline interpolation of the unconstrained consumption function for this period.

Parameters:
  • mNrm (np.array) – Corresponding market resource points for interpolation.
  • cNrm (np.array) – Consumption points for interpolation.
Returns:

cFuncUnc – The unconstrained consumption function for this period.

Return type:

CubicInterp

makeEndOfPrdvFunc(EndOfPrdvP)

Construct the end-of-period value function for this period, storing it as an attribute of self for use by other methods.

Parameters:EndOfPrdvP (np.array) – Array of end-of-period marginal value of assets corresponding to the asset values in self.aNrmNow.
Returns:
Return type:none
makevFunc(solution)

Creates the value function for this period, defined over market resources m. self must have the attribute EndOfPrdvFunc in order to execute.

Parameters:solution (ConsumerSolution) – The solution to this single period problem, which must include the consumption function.
Returns:vFuncNow – A representation of the value function for this period, defined over normalized market resources m: v = vFuncNow(m).
Return type:ValueFunc
solve()

Solves the single period consumption-saving problem using the method of endogenous gridpoints. Solution includes a consumption function cFunc (using cubic or linear splines), a marginal value function vPfunc, a min- imum acceptable level of normalized market resources mNrmMin, normalized human wealth hNrm, and bounding MPCs MPCmin and MPCmax. It might also have a value function vFunc and marginal marginal value function vPPfunc.

Parameters:none
Returns:solution – The solution to the single period consumption-saving problem.
Return type:ConsumerSolution
class HARK.ConsumptionSaving.ConsIndShockModel.ConsIndShockSolverBasic(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

This class solves a single period of a standard consumption-saving problem, using linear interpolation and without the ability to calculate the value function. ConsIndShockSolver inherits from this class and adds the ability to perform cubic interpolation and to calculate the value function.

Note that this class does not have its own initializing method. It initial- izes the same problem in the same way as ConsIndShockSetup, from which it inherits.

addMPCandHumanWealth(solution)

Take a solution and add human wealth and the bounding MPCs to it.

Parameters:
  • solution (ConsumerSolution) – The solution to this period’s consumption-saving problem.
  • Returns
  • ----------
  • solution – The solution to this period’s consumption-saving problem, but now with human wealth and the bounding MPCs.
calcEndOfPrdvP()

Calculate end-of-period marginal value of assets at each point in aNrmNow. Does so by taking a weighted sum of next period marginal values across income shocks (in a preconstructed grid self.mNrmNext).

Parameters:none
Returns:EndOfPrdvP – A 1D array of end-of-period marginal value of assets
Return type:np.array
getPointsForInterpolation(EndOfPrdvP, aNrmNow)

Finds interpolation points (c,m) for the consumption function.

Parameters:
  • EndOfPrdvP (np.array) – Array of end-of-period marginal values.
  • aNrmNow (np.array) – Array of end-of-period asset values that yield the marginal values in EndOfPrdvP.
Returns:

  • c_for_interpolation (np.array) – Consumption points for interpolation.
  • m_for_interpolation (np.array) – Corresponding market resource points for interpolation.

makeBasicSolution(EndOfPrdvP, aNrm, interpolator)

Given end of period assets and end of period marginal value, construct the basic solution for this period.

Parameters:
  • EndOfPrdvP (np.array) – Array of end-of-period marginal values.
  • aNrm (np.array) – Array of end-of-period asset values that yield the marginal values in EndOfPrdvP.
  • interpolator (function) – A function that constructs and returns a consumption function.
Returns:

solution_now – The solution to this period’s consumption-saving problem, with a consumption function, marginal value function, and minimum m.

Return type:

ConsumerSolution

makeLinearcFunc(mNrm, cNrm)

Makes a linear interpolation to represent the (unconstrained) consumption function.

Parameters:
  • mNrm (np.array) – Corresponding market resource points for interpolation.
  • cNrm (np.array) – Consumption points for interpolation.
Returns:

cFuncUnc – The unconstrained consumption function for this period.

Return type:

LinearInterp

prepareToCalcEndOfPrdvP()

Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period.

Parameters:none
Returns:aNrmNow – A 1D array of end-of-period assets; also stored as attribute of self.
Return type:np.array
solve()

Solves a one period consumption saving problem with risky income.

Parameters:None
Returns:solution – The solution to the one period problem.
Return type:ConsumerSolution
usePointsForInterpolation(cNrm, mNrm, interpolator)

Constructs a basic solution for this period, including the consumption function and marginal value function.

Parameters:
  • cNrm (np.array) – (Normalized) consumption points for interpolation.
  • mNrm (np.array) – (Normalized) corresponding market resource points for interpolation.
  • interpolator (function) – A function that constructs and returns a consumption function.
Returns:

solution_now – The solution to this period’s consumption-saving problem, with a consumption function, marginal value function, and minimum m.

Return type:

ConsumerSolution

class HARK.ConsumptionSaving.ConsIndShockModel.ConsKinkedRsolver(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rboro, Rsave, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

A class to solve a single period consumption-saving problem where the interest rate on debt differs from the interest rate on savings. Inherits from ConsIndShockSolver, with nearly identical inputs and outputs. The key diff- erence is that Rfree is replaced by Rsave (a>0) and Rboro (a<0). The solver can handle Rboro == Rsave, which makes it identical to ConsIndShocksolver, but it terminates immediately if Rboro < Rsave, as this has a different solution.

makeCubiccFunc(mNrm, cNrm)

Makes a cubic spline interpolation that contains the kink of the unconstrained consumption function for this period.

Parameters:
  • mNrm (np.array) – Corresponding market resource points for interpolation.
  • cNrm (np.array) – Consumption points for interpolation.
Returns:

cFuncUnc – The unconstrained consumption function for this period.

Return type:

CubicInterp

prepareToCalcEndOfPrdvP()

Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period. This differs from the baseline case because different savings choices yield different interest rates.

Parameters:none
Returns:aNrmNow – A 1D array of end-of-period assets; also stored as attribute of self.
Return type:np.array
class HARK.ConsumptionSaving.ConsIndShockModel.ConsPerfForesightSolver(solution_next, DiscFac, LivPrb, CRRA, Rfree, PermGroFac, BoroCnstArt, MaxKinks)

A class for solving a one period perfect foresight consumption-saving problem. An instance of this class is created by the function solvePerfForesight in each period.

addSSmNrm(solution)

Finds steady state (normalized) market resources and adds it to the solution. This is the level of market resources such that the expectation of market resources in the next period is unchanged. This value doesn’t necessarily exist.

Parameters:solution (ConsumerSolution) – Solution to this period’s problem, which must have attribute cFunc.
Returns:solution – Same solution that was passed, but now with the attribute mNrmSS.
Return type:ConsumerSolution
assignParameters(solution_next, DiscFac, LivPrb, CRRA, Rfree, PermGroFac, BoroCnstArt, MaxKinks)

Saves necessary parameters as attributes of self for use by other methods.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • DiscFac (float) – Intertemporal discount factor for future utility.
  • LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period.
  • CRRA (float) – Coefficient of relative risk aversion.
  • Rfree (float) – Risk free interest factor on end-of-period assets.
  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.
  • BoroCnstArt (float or None) – Artificial borrowing constraint, as a multiple of permanent income. Can be None, indicating no artificial constraint.
  • MaxKinks (int) – Maximum number of kink points to allow in the consumption function; additional points will be thrown out.
Returns:

Return type:

None

defUtilityFuncs()

Defines CRRA utility function for this period (and its derivatives), saving them as attributes of self for other methods to use.

Parameters:None
Returns:
Return type:None
defValueFuncs()
Defines the value and marginal value functions for this period. Uses the fact that for a perfect foresight CRRA utility problem, if the MPC in period t is \(\kappa_{t}\), and relative risk aversion :math:`
ho`, then the inverse value vFuncNvrs has a
constant slope of :math:`kappa_{t}^{-

ho/(1- ho)}` and

vFuncNvrs has value of zero at the lower bound of market resources mNrmMin. See PerfForesightConsumerType.ipynb documentation notebook for a brief explanation and the links below for a fuller treatment.

https://econ.jhu.edu/people/ccarroll/public/lecturenotes/consumption/PerfForesightCRRA/#vFuncAnalytical https://econ.jhu.edu/people/ccarroll/SolvingMicroDSOPs/#vFuncPF

None

None

makePFcFunc()

Makes the (linear) consumption function for this period.

Parameters:None
Returns:
Return type:None
solve()

Solves the one period perfect foresight consumption-saving problem.

Parameters:None
Returns:solution – The solution to this period’s problem.
Return type:ConsumerSolution
class HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution(cFunc=None, vFunc=None, vPfunc=None, vPPfunc=None, mNrmMin=None, hNrm=None, MPCmin=None, MPCmax=None)

A class representing the solution of a single period of a consumption-saving problem. The solution must include a consumption function and marginal value function.

Here and elsewhere in the code, Nrm indicates that variables are normalized by permanent income.

appendSolution(new_solution)

Appends one solution to another to create a ConsumerSolution whose attributes are lists. Used in ConsMarkovModel, where we append solutions conditional on a particular value of a Markov state to each other in order to get the entire solution.

Parameters:new_solution (ConsumerSolution) – The solution to a consumption-saving problem; each attribute is a list representing state-conditional values or functions.
Returns:
Return type:None
class HARK.ConsumptionSaving.ConsIndShockModel.IndShockConsumerType(cycles=1, time_flow=True, verbose=False, quiet=False, **kwds)

A consumer type with idiosyncratic shocks to permanent and transitory income. His problem is defined by a sequence of income distributions, survival prob- abilities, and permanent income growth rates, as well as time invariant values for risk aversion, discount factor, the interest rate, the grid of end-of- period assets, and an artificial borrowing constraint.

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.

Parameters:None
Returns:
Return type:None
checkConditions(verbose=False, public_call=True)

This method checks whether the instance’s type satisfies the Growth Impatience Condition (GIC), Return Impatience Condition (RIC), Absolute Impatience Condition (AIC), Weak Return Impatience Condition (WRIC), Finite Human Wealth Condition (FHWC) and Finite Value of Autarky Condition (FVAC). These are the conditions that are sufficient for nondegenerate infinite horizon solutions when there is a 1 period cycle. Depending on the model at hand, a different combination of these conditions must be satisfied. (For an exposition of the conditions, see http://econ.jhu.edu/people/ccarroll/papers/BufferStockTheory/)

Parameters:verbose (boolean) – Specifies different levels of verbosity of feedback. When False, it only reports whether the instance’s type fails to satisfy a particular condition. When True, it reports all results, i.e. the factor values for all conditions.
Returns:
Return type:None
getShocks()

Gets permanent and transitory income shocks for this period. Samples from IncomeDstn for each period in the cycle.

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

Only works on (one period) infinite horizon models at this time, will be generalized later.

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

Return type:

None

update()

Update the income process, the assets grid, and the terminal solution.

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

Updates this agent’s end-of-period assets grid by constructing a multi- exponentially spaced grid of aXtra values.

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

Updates this agent’s income process based on his own attributes.

Parameters:
  • none
  • Returns
  • -----------
  • none
class HARK.ConsumptionSaving.ConsIndShockModel.KinkedRconsumerType(cycles=1, time_flow=True, **kwds)

A consumer type that faces idiosyncratic shocks to income and has a different interest factor on saving vs borrowing. Extends IndShockConsumerType, with very small changes. Solver for this class is currently only compatible with linear spline interpolation.

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. This version deals with the different interest rates on borrowing vs saving.

Parameters:None
Returns:
Return type:None
checkConditions(verbose=False)

This method checks whether the instance’s type satisfies the Growth Impatience Condition (GIC), Return Impatience Condition (RIC), Absolute Impatience Condition (AIC), Weak Return Impatience Condition (WRIC), Finite Human Wealth Condition (FHWC) and Finite Value of Autarky Condition (FVAC). These are the conditions that are sufficient for nondegenerate infinite horizon solutions with a 1 period cycle. Depending on the model at hand, a different combination of these conditions must be satisfied. To check which conditions are relevant to the model at hand, a reference to the relevant theoretical literature is made.

SHOULD BE INHERITED FROM ConsIndShockModel

Parameters:verbose (boolean) – Specifies different levels of verbosity of feedback. When False, it only reports whether the instance’s type fails to satisfy a particular condition. When True, it reports all results, i.e. the factor values for all conditions.
Returns:
Return type:None
getRfree()

Returns an array of size self.AgentCount with self.Rboro or self.Rsave in each entry, based on whether self.aNrmNow >< 0.

Parameters:None
Returns:RfreeNow – Array of size self.AgentCount with risk free interest rate for each agent.
Return type:np.array
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.

SHOULD BE INHERITED FROM ConsIndShockModel

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

Return type:

None

class HARK.ConsumptionSaving.ConsIndShockModel.MargMargValueFunc(cFunc, CRRA)

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

class HARK.ConsumptionSaving.ConsIndShockModel.MargValueFunc(cFunc, CRRA)

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

derivative(m)

Evaluate the derivative of the marginal value function at given levels of market resources m; this is the marginal marginal value function.

Parameters:m (float or np.array) – Market resources (normalized by permanent income) whose marginal marginal value is to be found.
Returns:vPP – Marginal marginal lifetime value of beginning this period with market resources m; has same size as input m.
Return type:float or np.array
class HARK.ConsumptionSaving.ConsIndShockModel.PerfForesightConsumerType(cycles=1, time_flow=True, verbose=False, quiet=False, **kwds)

A perfect foresight consumer type who has no uncertainty other than mortality. His problem is defined by a coefficient of relative risk aversion, intertemporal discount factor, interest factor, an artificial borrowing constraint (maybe) and time sequences of the permanent income growth rate and survival probability.

checkConditions(verbose=False, verbose_reference=False, public_call=False)

This method checks whether the instance’s type satisfies the Growth Impatience Condition (GIC), Return Impatience Condition (RIC), Absolute Impatience Condition (AIC), Weak Return Impatience Condition (WRIC), Finite Human Wealth Condition (FHWC) and Finite Value of Autarky Condition (FVAC). These are the conditions that are sufficient for nondegenerate solutions under infinite horizon with a 1 period cycle. Depending on the model at hand, a different combination of these conditions must be satisfied. To check which conditions are relevant to the model at hand, a reference to the relevant theoretical literature is made.

Parameters:verbose (boolean) – Specifies different levels of verbosity of feedback. When False, it only reports whether the instance’s type fails to satisfy a particular condition. When True, it reports all results, i.e. the factor values for all conditions.
Returns:
Return type:None
checkRestrictions()

A method to check that various restrictions are met for the model class.

getControls()

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

Parameters:None
Returns:
Return type:None
getPostStates()

Calculates end-of-period assets for each consumer of this type.

Parameters:None
Returns:
Return type:None
getRfree()

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

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

Finds permanent and transitory income “shocks” for each agent this period. As this is a perfect foresight model, there are no stochastic shocks: PermShkNow = PermGroFac for each agent (according to their t_cycle) and TranShkNow = 1.0 for all agents.

Parameters:None
Returns:
Return type:None
getStates()

Calculates updated values of normalized market resources and permanent income level for each agent. Uses pLvlNow, aNrmNow, PermShkNow, TranShkNow.

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

Determines which agents die this period and must be replaced. Uses the sequence in LivPrb to determine survival probabilities for each agent.

Parameters:None
Returns:which_agents – Boolean array of size AgentCount indicating which agents die.
Return type:np.array(bool)
unpackcFunc()

“Unpacks” the consumption functions into their own field for easier access. After the model has been solved, the consumption functions reside in the attribute cFunc of each element of ConsumerType.solution. This method creates a (time varying) attribute cFunc that contains a list of consumption functions.

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

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.ConsIndShockModel.ValueFunc(vFuncNvrs, CRRA)

A class for representing a value function. The underlying interpolation is in the space of (m,u_inv(v)); this class “re-curves” to the value function.

HARK.ConsumptionSaving.ConsIndShockModel.applyFlatIncomeTax(IncomeDstn, tax_rate, T_retire, unemployed_indices=[], transitory_index=2)

Applies a flat income tax rate to all employed income states during the working period of life (those before T_retire). Time runs forward in this function.

Parameters:
  • IncomeDstn ([income distributions]) – The discrete approximation to the income distribution in each time period.
  • tax_rate (float) – A flat income tax rate to be applied to all employed income.
  • T_retire (int) – The time index after which the agent retires.
  • unemployed_indices ([int]) – Indices of transitory shocks that represent unemployment states (no tax).
  • transitory_index (int) – The index of each element of IncomeDstn representing transitory shocks.
Returns:

IncomeDstn_new – The updated income distributions, after applying the tax.

Return type:

[income distributions]

HARK.ConsumptionSaving.ConsIndShockModel.constructAssetsGrid(parameters)

Constructs the base grid of post-decision states, representing end-of-period assets above the absolute minimum.

All parameters are passed as attributes of the single input parameters. The input can be an instance of a ConsumerType, or a custom Parameters class.

Parameters:
  • aXtraMin (float) – Minimum value for the a-grid
  • aXtraMax (float) – Maximum value for the a-grid
  • aXtraCount (int) – Size of the a-grid
  • aXtraExtra ([float]) – Extra values for the a-grid.
  • exp_nest (int) – Level of nesting for the exponentially spaced grid
Returns:

aXtraGrid – Base array of values for the post-decision-state grid.

Return type:

np.ndarray

HARK.ConsumptionSaving.ConsIndShockModel.constructLognormalIncomeProcessUnemployment(parameters)

Generates a list of discrete approximations to the income process for each life period, from end of life to beginning of life. Permanent shocks are mean one lognormally distributed with standard deviation PermShkStd[t] during the working life, and degenerate at 1 in the retirement period. Transitory shocks are mean one lognormally distributed with a point mass at IncUnemp with probability UnempPrb while working; they are mean one with a point mass at IncUnempRet with probability UnempPrbRet. Retirement occurs after t=T_retire periods of working.

Note 1: All time in this function runs forward, from t=0 to t=T

Note 2: All parameters are passed as attributes of the input parameters.

PermShkStd : [float]
List of standard deviations in log permanent income uncertainty during the agent’s life.
PermShkCount : int
The number of approximation points to be used in the discrete approxima- tion to the permanent income shock distribution.
TranShkStd : [float]
List of standard deviations in log transitory income uncertainty during the agent’s life.
TranShkCount : int
The number of approximation points to be used in the discrete approxima- tion to the permanent income shock distribution.
UnempPrb : float
The probability of becoming unemployed during the working period.
UnempPrbRet : float
The probability of not receiving typical retirement income when retired.
T_retire : int
The index value for the final working period in the agent’s life. If T_retire <= 0 then there is no retirement.
IncUnemp : float
Transitory income received when unemployed.
IncUnempRet : float
Transitory income received while “unemployed” when retired.
T_cycle : int
Total number of non-terminal periods in the consumer’s sequence of periods.
Returns:
  • IncomeDstn ([[np.array]]) – A list with T_cycle elements, each of which is a list of three arrays representing a discrete approximation to the income process in a period. Order: probabilities, permanent shocks, transitory shocks.
  • PermShkDstn ([[np.array]]) – A list with T_cycle elements, each of which is a list of two arrays representing a discrete approximation to the permanent income shocks.
  • TranShkDstn ([[np.array]]) – A list with T_cycle elements, each of which is a list of two arrays representing a discrete approximation to the transitory income shocks.
HARK.ConsumptionSaving.ConsIndShockModel.solveConsIndShock(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

Solves a single period consumption-saving problem with CRRA utility and risky income (subject to permanent and transitory shocks). Can generate a value function if requested; consumption function can be linear or cubic splines.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn ([np.array]) – A list containing three 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, permanent shocks, 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.
  • Rfree (float) – Risk free interest factor on end-of-period assets.
  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.
  • BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
  • aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level.
  • vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.
  • CubicBool (boolean) – Indicator for whether the solver should use cubic or linear interpolation.
Returns:

solution_now – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (using cubic or linear splines), a marginal value function vPfunc, a minimum acceptable level of normalized market resources mNrmMin, normalized human wealth hNrm, and bounding MPCs MPCmin and MPCmax. It might also have a value function vFunc and marginal mar- ginal value function vPPfunc.

Return type:

ConsumerSolution

HARK.ConsumptionSaving.ConsIndShockModel.solveConsKinkedR(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rboro, Rsave, PermGroFac, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

Solves a single period consumption-saving problem with CRRA utility and risky income (subject to permanent and transitory shocks), and different interest factors on borrowing and saving. Restriction: Rboro >= Rsave. Currently cannot construct a cubic spline consumption function, only linear. Can gen- erate a value function if requested.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn ([np.array]) – A list containing three 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, permanent shocks, 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.
  • Rboro (float) – Interest factor on assets between this period and the succeeding period when assets are negative.
  • Rsave (float) – Interest factor on assets between this period and the succeeding period when assets are positive.
  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.
  • BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
  • aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level.
  • vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.
  • CubicBool (boolean) – Indicator for whether the solver should use cubic or linear interpolation.
Returns:

solution_now – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (using cubic or linear splines), a marginal value function vPfunc, a minimum acceptable level of normalized market resources mNrmMin, normalized human wealth hNrm, and bounding MPCs MPCmin and MPCmax. It might also have a value function vFunc.

Return type:

ConsumerSolution

HARK.ConsumptionSaving.ConsIndShockModel.solvePerfForesight(solution_next, DiscFac, LivPrb, CRRA, Rfree, PermGroFac, BoroCnstArt, MaxKinks)

Solves a single period consumption-saving problem for a consumer with perfect foresight.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • DiscFac (float) – Intertemporal discount factor for future utility.
  • LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period.
  • CRRA (float) – Coefficient of relative risk aversion.
  • Rfree (float) – Risk free interest factor on end-of-period assets.
  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.
  • BoroCnstArt (float or None) – Artificial borrowing constraint, as a multiple of permanent income. Can be None, indicating no artificial constraint.
  • MaxKinks (int) – Maximum number of kink points to allow in the consumption function; additional points will be thrown out. Only relevant in infinite horizon models with artificial borrowing constraint.
Returns:

solution_now – The solution to this period’s problem.

Return type:

ConsumerSolution