HARK.ConsumptionSaving.ConsMarkovModel

Classes to solve and simulate consumption-savings model with a discrete, exogenous, stochastic Markov state. The only solver here extends ConsIndShockModel to include a Markov state; the interest factor, permanent growth factor, and income distribution can vary with the discrete state.

class HARK.ConsumptionSaving.ConsMarkovModel.ConsMarkovSolver(solution_next, IncomeDstn_list, LivPrb, DiscFac, CRRA, Rfree_list, PermGroFac_list, MrkvArray, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

A class to solve a single period consumption-saving problem with risky income and stochastic transitions between discrete states, in a Markov fashion. Extends ConsIndShockSolver, with identical inputs but for a discrete Markov state, whose transition rule is summarized in MrkvArray. Markov states can differ in their interest factor, permanent growth factor, live probability, and income distribution, so the inputs Rfree, PermGroFac, IncomeDstn, and LivPrb are now arrays or lists specifying those values in each (succeeding) Markov state.

calcEndOfPrdvP()

Calculates end of period marginal value (and marginal marginal) value at each aXtra gridpoint for each current state, unconditional on the future Markov state (i.e. weighting conditional end-of-period marginal value by transition probabilities).

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

Calculates end-of-period marginal marginal value using a pre-defined array of next period market resources in self.mNrmNext.

Parameters:none
Returns:EndOfPrdvPP – End-of-period marginal marginal value of assets at each value in the grid of assets.
Return type:np.array
calcEndOfPrdvPcond()

Calculate end-of-period marginal value of assets at each point in aNrmNow conditional on a particular state occuring in the next period.

Parameters:None
Returns:EndOfPrdvP – A 1D array of end-of-period marginal value of assets.
Return type:np.array
calcHumWealthAndBoundingMPCs()

Calculates human wealth and the maximum and minimum MPC for each current period state, then stores them as attributes of self for use by other methods.

Parameters:none
Returns:
Return type:none
conditionOnState(state_index)

Temporarily assume that a particular Markov state will occur in the succeeding period, and condition solver attributes on this assumption. Allows the solver to construct the future-state-conditional marginal value function (etc) for that future state.

Parameters:state_index (int) – Index of the future Markov state to condition on.
Returns:
Return type:none
defBoundary()

Find the borrowing constraint for each current state and save it as an attribute of self for use by other methods.

Parameters:none
Returns:
Return type:none
makeCubiccFunc(mNrm, cNrm)

Make a cubic interpolation to represent the (unconstrained) consumption function conditional on the current period state.

Parameters:
  • mNrm (np.array) – Array of normalized market resource values for interpolation.
  • cNrm (np.array) – Array of normalized consumption values for interpolation.
Returns:

cFuncUnc

Return type:

an instance of HARK.interpolation.CubicInterp

makeEndOfPrdvFuncCond()

Construct the end-of-period value function conditional on next period’s state. NOTE: It might be possible to eliminate this method and replace it with ConsIndShockSolver.makeEndOfPrdvFunc, but the self.X_cond variables must be renamed.

Parameters:none
Returns:EndofPrdvFunc_cond – The end-of-period value function conditional on a particular state occuring in the next period.
Return type:ValueFunc
makeEndOfPrdvPfuncCond()

Construct the end-of-period marginal value function conditional on next period’s state.

Parameters:None
Returns:EndofPrdvPfunc_cond – The end-of-period marginal value function conditional on a particular state occuring in the succeeding period.
Return type:MargValueFunc
makeLinearcFunc(mNrm, cNrm)

Make a linear interpolation to represent the (unconstrained) consumption function conditional on the current period state.

Parameters:
  • mNrm (np.array) – Array of normalized market resource values for interpolation.
  • cNrm (np.array) – Array of normalized consumption values for interpolation.
Returns:

cFuncUnc

Return type:

an instance of HARK.interpolation.LinearInterp

makeSolution(cNrm, mNrm)

Construct an object representing the solution to this period’s problem.

Parameters:
  • cNrm (np.array) – Array of normalized consumption values for interpolation. Each row corresponds to a Markov state for this period.
  • mNrm (np.array) – Array of normalized market resource values for interpolation. Each row corresponds to a Markov state for this period.
Returns:

solution – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (using cubic or linear splines), a marg- inal 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 marginal value function vPPfunc. All of these attributes are lists or arrays, with elements corresponding to the current Markov state. E.g. solution.cFunc[0] is the consumption function when in the i=0 Markov state this period.

Return type:

ConsumerSolution

makevFunc(solution)

Construct the value function for each current state.

Parameters:solution (ConsumerSolution) – The solution to the single period consumption-saving problem. Must have a consumption function cFunc (using cubic or linear splines) as a list with elements corresponding to the current Markov state. E.g. solution.cFunc[0] is the consumption function when in the i=0 Markov state this period.
Returns:vFuncNow – A list of value functions (defined over normalized market resources m) for each current period Markov state.
Return type:[ValueFunc]
solve()

Solve the one period problem of the consumption-saving model with a Markov state.

Parameters:none
Returns:solution – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (using cubic or linear splines), a marg- inal 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 marginal value function vPPfunc. All of these attributes are lists or arrays, with elements corresponding to the current Markov state. E.g. solution.cFunc[0] is the consumption function when in the i=0 Markov state this period.
Return type:ConsumerSolution
class HARK.ConsumptionSaving.ConsMarkovModel.MarkovConsumerType(cycles=1, time_flow=True, **kwds)

An agent in the Markov consumption-saving model. His problem is defined by a sequence of income distributions, survival probabilities, discount factors, and permanent income growth rates, as well as time invariant values for risk aversion, the interest rate, the grid of end-of-period assets, and how he is borrowing constrained.

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. Results are all np.array with elements corresponding to each Markov state.

NOT YET IMPLEMENTED FOR THIS CLASS

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

Many parameters used by MarkovConsumerType are arrays. Make sure those arrays are the right shape.

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

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

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

Returns an array of size self.AgentCount with interest factor that varies with discrete state.

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

Gets new Markov states and permanent and transitory income shocks for this period. Samples from IncomeDstn for each period-state 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.

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

Return type:

None

preSolve()

Check to make sure that the inputs that are specific to MarkovConsumerType are of the right shape (if arrays) or length (if lists).

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

A slight modification of AgentType.readShocks that makes sure that MrkvNow is int, not float.

Parameters:None
Returns:
Return type:None
simBirth(which_agents)

Makes new Markov consumer by drawing initial normalized assets, permanent income levels, and discrete states. Calls IndShockConsumerType.simBirth, then draws from initial Markov distribution.

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)
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
HARK.ConsumptionSaving.ConsMarkovModel.solveConsMarkov(solution_next, IncomeDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, MrkvArray, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)

Solves a single period consumption-saving problem with risky income and stochastic transitions between discrete states, in a Markov fashion. Has identical inputs as solveConsIndShock, except for a discrete Markov transitionrule MrkvArray. Markov states can differ in their interest factor, permanent growth factor, and income distribution, so the inputs Rfree, PermGroFac, and IncomeDstn are arrays or lists specifying those values in each (succeeding) Markov state.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn_list ([[np.array]]) – A length N list of income distributions in each succeeding Markov state. Each income distribution contains three arrays of floats, representing a discrete approximation to the income process at the beginning of the succeeding period. 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_list (np.array) – Risk free interest factor on end-of-period assets for each Markov state in the succeeding period.
  • PermGroGac_list (float) – Expected permanent income growth factor at the end of this period for each Markov state in the succeeding period.
  • MrkvArray (numpy.array) – An NxN array representing a Markov transition matrix between discrete states. The i,j-th element of MrkvArray is the probability of moving from state i in period t to state j in period t+1.
  • 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:

solution – The solution to the single period consumption-saving problem. Includes a consumption function cFunc (using cubic or linear splines), a marg- inal 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 marginal value function vPPfunc. All of these attributes are lists or arrays, with elements corresponding to the current Markov state. E.g. solution.cFunc[0] is the consumption function when in the i=0 Markov state this period.

Return type:

ConsumerSolution