ConsMarkovModel¶
Classes to solve and simulate consumptionsavings 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, IncShkDstn_list, LivPrb, DiscFac, CRRA, Rfree_list, PermGroFac_list, MrkvArray, BoroCnstArt, aXtraGrid, vFuncBool, CubicBool)¶ Bases:
HARK.ConsumptionSaving.ConsIndShockModel.ConsIndShockSolver
A class to solve a single period consumptionsaving 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, IncShkDstn, and LivPrb are now arrays or lists specifying those values in each (succeeding) Markov state.

calc_EndOfPrdvP
()¶ 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 endofperiod marginal value by transition probabilities).
Parameters: none – Returns: Return type: none

calc_EndOfPrdvPP
()¶ Calculates endofperiod marginal marginal value using a predefined array of next period market resources in self.mNrmNext.
Parameters: none – Returns: EndOfPrdvPP – Endofperiod marginal marginal value of assets at each value in the grid of assets. Return type: np.array

calc_EndOfPrdvPcond
()¶ Calculate endofperiod 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 endofperiod marginal value of assets. Return type: np.array

calc_HumWealth_and_BoundingMPCs
()¶ 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

condition_on_state
(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 futurestateconditional 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

def_boundary
()¶ 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

make_EndOfPrdvFuncCond
()¶ Construct the endofperiod value function conditional on next period’s state. NOTE: It might be possible to eliminate this method and replace it with ConsIndShockSolver.make_EndOfPrdvFunc, but the self.X_cond variables must be renamed.
Parameters: none – Returns: EndofPrdvFunc_cond – The endofperiod value function conditional on a particular state occuring in the next period. Return type: ValueFuncCRRA

make_EndOfPrdvPfuncCond
()¶ Construct the endofperiod marginal value function conditional on next period’s state.
Parameters: None – Returns: EndofPrdvPfunc_cond – The endofperiod marginal value function conditional on a particular state occuring in the succeeding period. Return type: MargValueFuncCRRA

make_cubic_cFunc
(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

make_linear_cFunc
(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

make_solution
(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 consumptionsaving 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:

make_vFunc
(solution)¶ Construct the value function for each current state.
Parameters: solution (ConsumerSolution) – The solution to the single period consumptionsaving 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: [ValueFuncCRRA]

solve
()¶ Solve the one period problem of the consumptionsaving model with a Markov state.
Parameters: none – Returns: solution – The solution to the single period consumptionsaving 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, **kwds)¶ Bases:
HARK.ConsumptionSaving.ConsIndShockModel.IndShockConsumerType
An agent in the Markov consumptionsaving 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 endofperiod assets, and how he is borrowing constrained.

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. Results are all np.array with elements corresponding to each Markov state.
NOT YET IMPLEMENTED FOR THIS CLASS
Parameters: None – Returns: Return type: None

check_markov_inputs
()¶ Many parameters used by MarkovConsumerType are arrays. Make sure those arrays are the right shape.
Parameters: None – Returns: Return type: None

get_Rfree
()¶ 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

get_controls
()¶ Calculates consumption for each consumer of this type using the consumption functions.
Parameters: None – Returns: Return type: None

get_markov_states
()¶ Draw new Markov states for each agent in the simulated population, using the attribute MrkvArray to determine transition probabilities.
Parameters: None – Returns: Return type: None

get_shocks
()¶ Gets new Markov states and permanent and transitory income shocks for this period. Samples from IncShkDstn for each periodstate in the cycle.
Parameters: None – Returns: Return type: None

initialize_sim
()¶ Prepares this AgentType for a new simulation. Resets the internal random number generator, makes initial states for all agents (using sim_birth), clears histories of tracked variables.
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: Notes
This method is not used by any other code in the library. Rather, it is here for expository and benchmarking purposes.

pre_solve
()¶ 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

read_shocks_from_history
()¶ A slight modification of AgentType.read_shocks that makes sure that MrkvNow is int, not float.
Parameters: None – Returns: Return type: None

reset_rng
()¶ Extended method that ensures random shocks are drawn from the same sequence on each simulation, which is important for structural estimation. This method is called automatically by initialize_sim().
Parameters: None – Returns: Return type: None

shock_vars_
= ['PermShk', 'TranShk', 'Mrkv']¶

sim_birth
(which_agents)¶ Makes new Markov consumer by drawing initial normalized assets, permanent income levels, and discrete states. Calls IndShockConsumerType.sim_birth, 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

sim_death
()¶ 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)

state_vars
= ['pLvl', 'PlvlAgg', 'bNrm', 'mNrm', 'aNrm', 'Mrkv']¶

time_vary_
= ['LivPrb', 'PermGroFac', 'MrkvArray']¶

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
