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.MarkovConsumerType(**kwds)#
Bases:
IndShockConsumerType
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.
- time_vary_ = ['LivPrb', 'PermGroFac', 'MrkvArray']#
- shock_vars_ = ['PermShk', 'TranShk', 'Mrkv']#
- state_vars = ['pLvl', 'PlvlAgg', 'bNrm', 'mNrm', 'aNrm', 'aLvl', 'Mrkv']#
- update()#
Update the Markov array, the income process, the assets grid, and the terminal solution.
- Parameters:
None
- Return type:
None
- check_markov_inputs()#
Many parameters used by MarkovConsumerType are arrays. Make sure those arrays are the right shape.
- Parameters:
None
- Return type:
None
- 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
- 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
- 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
- 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)
- 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”.
- 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
- Return type:
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
- 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
- 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
- Return type:
None
- 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
- 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.
- Return type:
None
Notes
This method is not used by any other code in the library. Rather, it is here for expository and benchmarking purposes.