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, IncShkDstn_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, 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 end-of-period marginal value by transition probabilities).

Parameters: none – none
calc_EndOfPrdvPP()

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

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

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 – EndOfPrdvP – A 1D array of end-of-period marginal value of assets. 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 – 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 future-state-conditional marginal value function (etc) for that future state.

Parameters: state_index (int) – Index of the future Markov state to condition on. 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 – none
make_EndOfPrdvFuncCond()

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.make_EndOfPrdvFunc, but the self.X_cond variables must be renamed.

Parameters: none – EndofPrdvFunc_cond – The end-of-period value function conditional on a particular state occuring in the next period. ValueFuncCRRA
make_EndOfPrdvPfuncCond()

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

Parameters: None – EndofPrdvPfunc_cond – The end-of-period marginal value function conditional on a particular state occuring in the succeeding period. 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. cFuncUnc 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. cFuncUnc 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. 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. ConsumerSolution
make_vFunc(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. vFuncNow – A list of value functions (defined over normalized market resources m) for each current period Markov state. [ValueFuncCRRA]
solve()

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

Parameters: none – 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. ConsumerSolution
class HARK.ConsumptionSaving.ConsMarkovModel.MarkovConsumerType(**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.

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

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

Parameters: None – None
get_Rfree()

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

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

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

Parameters: None – 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 – None
get_shocks()

Gets new Markov states and permanent and transitory income shocks for this period. Samples from IncShkDstn for each period-state in the cycle.

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

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

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

Parameters: None – 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 – 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”. 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 – which_agents – Boolean array of size AgentCount indicating which agents die. 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 – none