ConsIndShockModel#
Classes to solve canonical consumption-saving models with idiosyncratic shocks to income. All models here assume CRRA utility with geometric discounting, no bequest motive, and income shocks that are fully transitory or fully permanent.
- It currently solves three types of models:
A very basic “perfect foresight” consumption-savings model with no uncertainty.
A consumption-savings model with risk over transitory and permanent income shocks.
The model described in (2), with an interest rate for debt that differs from the interest rate for savings.
See NARK econ-ark/HARK for information on variable naming conventions. See HARK documentation for mathematical descriptions of the models being solved.
- class HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution(cFunc=None, vFunc=None, vPfunc=None, vPPfunc=None, mNrmMin=None, hNrm=None, MPCmin=None, MPCmax=None)#
Bases:
MetricObject
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.
- Parameters:
cFunc (function) – The consumption function for this period, defined over normalized market resources: cNrm = cFunc(mNrm).
vFunc (function) – The beginning-of-period value function for this period, defined over normalized market resources: vNrm = vFunc(mNrm).
vPfunc (function) – The beginning-of-period marginal value function for this period, defined over normalized market resources: vNrmP = vPfunc(mNrm).
vPPfunc (function) – The beginning-of-period marginal marginal value function for this period, defined over normalized market resources: vNrmPP = vPPfunc(mNrm).
mNrmMin (float) – The minimum allowable normalized market resources for this period; the consump- tion function (etc) are undefined for m < mNrmMin.
hNrm (float) – Normalized human wealth after receiving income this period: PDV of all future income, ignoring mortality.
MPCmin (float) – Infimum of the marginal propensity to consume this period. MPC –> MPCmin as m –> infinity.
MPCmax (float) – Supremum of the marginal propensity to consume this period. MPC –> MPCmax as m –> mNrmMin.
- distance_criteria = ['vPfunc']#
- append_solution(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.
- Return type:
None
- class HARK.ConsumptionSaving.ConsIndShockModel.PerfForesightConsumerType(verbose=1, quiet=False, **kwds)#
Bases:
AgentType
A perfect foresight consumer type who has no uncertainty other than mortality. Their problem is defined by a coefficient of relative risk aversion (\(\rho\)), intertemporal discount factor (\(\beta\)), interest factor (\(\mathsf{R}\)), an optional artificial borrowing constraint (\(\underline{a}\)) and time sequences of the permanent income growth rate (\(\Gamma\)) and survival probability (\(1-\mathsf{D}\)). Their assets and income are normalized by permanent income.
\[\begin{split}\newcommand{\CRRA}{\rho} \newcommand{\DiePrb}{\mathsf{D}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \begin{align*} v_t(m_t) &= \max_{c_t}u(c_t) + \DiscFac (1 - \DiePrb_{t+1}) \PermGroFac_{t+1}^{1-\CRRA} v_{t+1}(m_{t+1}), \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= \Rfree_{t+1} a_t/\PermGroFac_{t+1} + 1, \\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \end{align*}\end{split}\]- Solving Parameters:
cycles (int) – 0 specifies an infinite horizon model, 1 specifies a finite model.
T_cycle (int) – Number of periods in the cycle for this agent type.
CRRA (float, \(\rho\)) – Coefficient of Relative Risk Aversion.
Rfree (float or list[float], time varying, \(\mathsf{R}\)) – Risk Free interest rate. Pass a list of floats to make Rfree time varying.
DiscFac (float, \(\beta\)) – Intertemporal discount factor.
LivPrb (list[float], time varying, \(1-\mathsf{D}\)) – Survival probability after each period.
PermGroFac (list[float], time varying, \(\Gamma\)) – Permanent income growth factor.
BoroCnstArt (float, \(\underline{a}\)) – The minimum Asset/Perminant Income ratio, None to ignore.
MaxKinks (int) – Maximum number of gridpoints to allow in cFunc.
- Simulation Parameters:
AgentCount (int) – Number of agents of this kind that are created during simulations.
T_age (int) – Age after which to automatically kill agents, None to ignore.
T_sim (int, required for simulation) – Number of periods to simulate.
track_vars (list[strings]) – List of variables that should be tracked when running the simulation. For this agent, the options are ‘aLvl’, ‘aNrm’, ‘bNrm’, ‘cNrm’, ‘mNrm’, ‘pLvl’, and ‘who_dies’.
aLvl is the nominal asset level
aNrm is the normalized assets
bNrm is the normalized resources without this period’s labor income
cNrm is the normalized consumption
mNrm is the normalized market resources
pLvl is the permanent income level
who_dies is the array of which agents died
aNrmInitMean (float) – Mean of Log initial Normalized Assets.
aNrmInitStd (float) – Std of Log initial Normalized Assets.
pLvlInitMean (float) – Mean of Log initial permanent income.
pLvlInitStd (float) – Std of Log initial permanent income.
PermGroFacAgg (float) – Aggregate permanent income growth factor (The portion of PermGroFac attributable to aggregate productivity growth).
PerfMITShk (boolean) – Do Perfect Foresight MIT Shock (Forces Newborns to follow solution path of the agent they replaced if True).
- Attributes:
solution (list[Consumer solution object]) – Created by the
solve()
method. Finite horizon models create a list with T_cycle+1 elements, for each period in the solution. Infinite horizon solutions return a list with T_cycle elements for each period in the cycle.Visit
HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution
for more information about the solution.history (Dict[Array]) – Created by running the
simulate()
method. Contains the variables in track_vars. Each item in the dictionary is an array with the shape (T_sim,AgentCount). VisitHARK.core.AgentType.simulate
for more information.
- solving_defaults = {'BoroCnstArt': None, 'CRRA': 2.0, 'DiscFac': 0.96, 'LivPrb': [0.98], 'MaxKinks': 400, 'PermGroFac': [1.01], 'Rfree': 1.03, 'T_cycle': 1, 'constructors': {'solution_terminal': <function make_basic_CRRA_solution_terminal>}, 'cycles': 1}#
- simulation_defaults = {'AgentCount': 10000, 'PerfMITShk': False, 'PermGroFacAgg': 1.0, 'T_age': None, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.0}#
- cFunc_terminal_ = <HARK.interpolation.LinearInterp object>#
- vFunc_terminal_ = <HARK.interpolation.LinearInterp object>#
- solution_terminal_ = <HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution object>#
- time_vary_ = ['LivPrb', 'PermGroFac']#
- time_inv_ = ['CRRA', 'DiscFac', 'MaxKinks', 'BoroCnstArt']#
- state_vars = ['pLvl', 'PlvlAgg', 'bNrm', 'mNrm', 'aNrm', 'aLvl']#
- shock_vars_ = []#
- pre_solve()#
Method that is run automatically just before solution by backward iteration. Solves the (trivial) terminal period and does a quick check on the borrowing constraint and MaxKinks attribute (only relevant in constrained, infinite horizon problems).
- post_solve()#
Method that is run automatically at the end of a call to solve. Here, it simply calls calc_stable_points() if appropriate: an infinite horizon problem with a single repeated period in its cycle.
- Parameters:
None
- Return type:
None
- check_restrictions()#
A method to check that various restrictions are met for the model class.
- 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
- Return type:
none
- update_Rfree()#
Determines whether Rfree is time-varying or fixed.
- Parameters:
None
- Return type:
None
- unpack_cFunc()#
DEPRECATED: Use solution.unpack(‘cFunc’) instead. “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. :param 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
- sim_birth(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”.
- 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)
- get_shocks()#
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
- Return type:
None
- get_Rfree()#
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
- transition()#
- Parameters:
None
[Eventually
spec (to match dolo)
exogenous_prev
endogenous_prev
controls
exogenous
parameters]
- Returns:
endogenous_state – Tuple with new values of the endogenous states
- Return type:
()
- get_controls()#
Calculates consumption for each consumer of this type using the consumption functions.
- Parameters:
None
- Return type:
None
- get_poststates()#
Calculates end-of-period assets for each consumer of this type.
- Parameters:
None
- Return type:
None
- log_condition_result(name, result, message, verbose)#
Records the result of one condition check in the attribute condition_report of the bilt dictionary, and in the message log.
- Parameters:
name (string or None) – Name for the condition; if None, no test result is added to conditions.
result (bool) – An indicator for whether the condition was passed.
message (str) – The messages to record about the condition check.
verbose (bool) – Indicator for whether verbose messages should be included in the report.
- check_AIC(verbose=None)#
Evaluate and report on the Absolute Impatience Condition.
- check_GICRaw(verbose=None)#
Evaluate and report on the Growth Impatience Condition for the Perfect Foresight model.
- check_RIC(verbose=None)#
Evaluate and report on the Return Impatience Condition.
- check_FHWC(verbose=None)#
Evaluate and report on the Finite Human Wealth Condition.
- check_FVAC(verbose=None)#
Evaluate and report on the Finite Value of Autarky Condition under perfect foresight.
- describe_parameters()#
Make a string describing this instance’s parameter values, including their representation in code and symbolically.
- Returns:
param_desc – Description of parameters as a unicode string.
- Return type:
- calc_limiting_values()#
Compute various scalar values that are relevant to characterizing the solution to an infinite horizon problem. This method should only be called when T_cycle=1 and cycles=0, otherwise the values generated are meaningless. This method adds the following values to the instance in the dictionary attribute called bilt.
APFac : Absolute Patience Factor GPFacRaw : Growth Patience Factor FHWFac : Finite Human Wealth Factor RPFac : Return Patience Factor PFVAFac : Perfect Foresight Value of Autarky Factor cNrmPDV : Present Discounted Value of Autarky Consumption MPCmin : Limiting minimum MPC as market resources go to infinity MPCmax : Limiting maximum MPC as market resources approach minimum level. hNrm : Human wealth divided by permanent income. Delta_mNrm_ZeroFunc : Linear consumption function where expected change in market resource ratio is zero BalGroFunc : Linear consumption function where the level of market resources grows at the same rate as permanent income
- Return type:
None
- check_conditions(verbose=None)#
This method checks whether the instance’s type satisfies the Absolute Impatience Condition (AIC), the Return Impatience Condition (RIC), the Finite Human Wealth Condition (FHWC), the perfect foresight model’s Growth Impatience Condition (GICRaw) and Perfect Foresight Finite Value of Autarky Condition (FVACPF). Depending on the configuration of parameter values, somecombination of these conditions must be satisfied in order for the problem to have a nondegenerate solution. To check which conditions are required, in the verbose mode 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.
- Return type:
None
- calc_stable_points()#
If the problem is one that satisfies the conditions required for target ratios of different variables to permanent income to exist, and has been solved to within the self-defined tolerance, this method calculates the target values of market resources.
- Parameters:
None
- Return type:
None
- class HARK.ConsumptionSaving.ConsIndShockModel.IndShockConsumerType(verbose=1, quiet=False, **kwds)#
Bases:
PerfForesightConsumerType
A consumer type with idiosyncratic shocks to permanent and transitory income. Their problem is defined by a sequence of income distributions, survival probabilities (\(1-\mathsf{D}\)), and permanent income growth rates (\(\Gamma\)), as well as time invariant values for risk aversion (\(\rho\)), discount factor (\(\beta\)), the interest rate (\(\mathsf{R}\)), the grid of end-of-period assets, and an artificial borrowing constraint (\(\underline{a}\)).
\[\begin{split}\newcommand{\CRRA}{\rho} \newcommand{\DiePrb}{\mathsf{D}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \begin{align*} v_t(m_t) &= \max_{c_t}u(c_t) + \DiscFac (1 - \DiePrb_{t+1}) \mathbb{E}_{t} \left[ (\PermGroFac_{t+1} \psi_{t+1})^{1-\CRRA} v_{t+1}(m_{t+1}) \right], \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= a_t \Rfree_{t+1}/(\PermGroFac_{t+1} \psi_{t+1}) + \theta_{t+1}, \\ (\psi_{t+1},\theta_{t+1}) &\sim F_{t+1}, \\ \mathbb{E}[\psi]=\mathbb{E}[\theta] &= 1, \\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \end{align*}\end{split}\]- Constructors:
IncShkDstn (Constructor, \(\psi\), \(\theta\)) – The agent’s income shock distributions.
It’s default constructor is
HARK.Calibration.Income.IncomeProcesses.construct_lognormal_income_process_unemployment()
aXtraGrid (Constructor) – The agent’s asset grid.
It’s default constructor is
HARK.utilities.make_assets_grid()
- Solving Parameters:
cycles (int) – 0 specifies an infinite horizon model, 1 specifies a finite model.
T_cycle (int) – Number of periods in the cycle for this agent type.
CRRA (float, \(\rho\)) – Coefficient of Relative Risk Aversion.
Rfree (float or list[float], time varying, \(\mathsf{R}\)) – Risk Free interest rate. Pass a list of floats to make Rfree time varying.
DiscFac (float, \(\beta\)) – Intertemporal discount factor.
LivPrb (list[float], time varying, \(1-\mathsf{D}\)) – Survival probability after each period.
PermGroFac (list[float], time varying, \(\Gamma\)) – Permanent income growth factor.
BoroCnstArt (float, \(\underline{a}\)) – The minimum Asset/Perminant Income ratio, None to ignore.
vFuncBool (bool) – Whether to calculate the value function during solution.
CubicBool (bool) – Whether to use cubic spline interpoliation.
- Simulation Parameters:
AgentCount (int) – Number of agents of this kind that are created during simulations.
T_age (int) – Age after which to automatically kill agents, None to ignore.
T_sim (int, required for simulation) – Number of periods to simulate.
track_vars (list[strings]) – List of variables that should be tracked when running the simulation. For this agent, the options are ‘PermShk’, ‘TranShk’, ‘aLvl’, ‘aNrm’, ‘bNrm’, ‘cNrm’, ‘mNrm’, ‘pLvl’, and ‘who_dies’.
PermShk is the agent’s permanent income shock
TranShk is the agent’s transitory income shock
aLvl is the nominal asset level
aNrm is the normalized assets
bNrm is the normalized resources without this period’s labor income
cNrm is the normalized consumption
mNrm is the normalized market resources
pLvl is the permanent income level
who_dies is the array of which agents died
aNrmInitMean (float) – Mean of Log initial Normalized Assets.
aNrmInitStd (float) – Std of Log initial Normalized Assets.
pLvlInitMean (float) – Mean of Log initial permanent income.
pLvlInitStd (float) – Std of Log initial permanent income.
PermGroFacAgg (float) – Aggregate permanent income growth factor (The portion of PermGroFac attributable to aggregate productivity growth).
PerfMITShk (boolean) – Do Perfect Foresight MIT Shock (Forces Newborns to follow solution path of the agent they replaced if True).
NewbornTransShk (boolean) – Whether Newborns have transitory shock.
- Attributes:
solution (list[Consumer solution object]) – Created by the
solve()
method. Finite horizon models create a list with T_cycle+1 elements, for each period in the solution. Infinite horizon solutions return a list with T_cycle elements for each period in the cycle.Visit
HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution
for more information about the solution.history (Dict[Array]) – Created by running the
simulate()
method. Contains the variables in track_vars. Each item in the dictionary is an array with the shape (T_sim,AgentCount). VisitHARK.core.AgentType.simulate
for more information.
- IncShkDstn_defaults = {'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005}#
- aXtraGrid_defaults = {'aXtraCount': 48, 'aXtraExtra': None, 'aXtraMax': 20, 'aXtraMin': 0.001, 'aXtraNestFac': 3}#
- solving_defaults = {'BoroCnstArt': 0.0, 'CRRA': 2.0, 'CubicBool': False, 'DiscFac': 0.96, 'LivPrb': [0.98], 'PermGroFac': [1.01], 'Rfree': 1.03, 'T_cycle': 1, 'constructors': {'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'solution_terminal': <function make_basic_CRRA_solution_terminal>}, 'cycles': 1, 'vFuncBool': False}#
- simulation_defaults = {'AgentCount': 10000, 'NewbornTransShk': False, 'PerfMITShk': False, 'PermGroFacAgg': 1.0, 'T_age': None, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'neutral_measure': False, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.0}#
- time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool']#
- shock_vars_ = ['PermShk', 'TranShk']#
- update_income_process()#
Updates this agent’s income process based on his own attributes.
- Parameters:
none
Returns
-----------
none
- update_assets_grid()#
Updates this agent’s end-of-period assets grid by constructing a multi- exponentially spaced grid of aXtra values.
- Parameters:
none
- Return type:
none
- update()#
Update the income process, the assets grid, and the terminal solution.
- Parameters:
None
- Return type:
None
- reset_rng()#
Reset the RNG behavior of this type. This method is called automatically by initialize_sim(), ensuring that each simulation run uses the same sequence of random shocks; this is necessary for structural estimation to work. This method extends AgentType.reset_rng() to also reset elements of IncShkDstn.
- Parameters:
None
- Return type:
None
- get_shocks()#
Gets permanent and transitory income shocks for this period. Samples from IncShkDstn for each period in the cycle.
- Parameters:
NewbornTransShk (boolean, optional) – Whether Newborns have transitory shock. The default is False.
- 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.
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.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.
- pre_solve()#
Method that is run automatically just before solution by backward iteration. Solves the (trivial) terminal period and does a quick check on the borrowing constraint and MaxKinks attribute (only relevant in constrained, infinite horizon problems).
- describe_parameters()#
Generate a string describing the primitive model parameters that will be used to calculating limiting values and factors.
- Parameters:
None
- Returns:
param_desc – Description of primitive parameters.
- Return type:
- calc_limiting_values()#
Compute various scalar values that are relevant to characterizing the solution to an infinite horizon problem. This method should only be called when T_cycle=1 and cycles=0, otherwise the values generated are meaningless. This method adds the following values to this instance in the dictionary attribute called bilt.
APFac : Absolute Patience Factor GPFacRaw : Growth Patience Factor GPFacMod : Risk-Modified Growth Patience Factor GPFacLiv : Mortality-Adjusted Growth Patience Factor GPFacLivMod : Modigliani Mortality-Adjusted Growth Patience Factor GPFacSdl : Szeidl Growth Patience Factor FHWFac : Finite Human Wealth Factor RPFac : Return Patience Factor WRPFac : Weak Return Patience Factor PFVAFac : Perfect Foresight Value of Autarky Factor VAFac : Value of Autarky Factor cNrmPDV : Present Discounted Value of Autarky Consumption MPCmin : Limiting minimum MPC as market resources go to infinity MPCmax : Limiting maximum MPC as market resources approach minimum level hNrm : Human wealth divided by permanent income. ELogPermShk : Expected log permanent income shock WorstPrb : Probability of worst income shock realization Delta_mNrm_ZeroFunc : Linear locus where expected change in market resource ratio is zero BalGroFunc : Linear consumption function where the level of market resources grows at the same rate as permanent income
- Return type:
None
- check_GICMod(verbose=None)#
Evaluate and report on the Risk-Modified Growth Impatience Condition.
- check_GICSdl(verbose=None)#
Evaluate and report on the Szeidl variation of the Growth Impatience Condition.
- check_GICHrm(verbose=None)#
Evaluate and report on the Harmenberg variation of the Growth Impatience Condition.
- check_GICLiv(verbose=None)#
Evaluate and report on the Mortality-Adjusted Growth Impatience Condition.
- check_FVAC(verbose=None)#
Evaluate and report on the Finite Value of Autarky condition in the presence of income risk.
- check_WRIC(verbose=None)#
Evaluate and report on the Weak Return Impatience Condition.
- check_conditions(verbose=None)#
This method checks whether the instance’s type satisfies various conditions. When combinations of these conditions are satisfied, the solution to the problem exhibits different characteristics. (For an exposition of the conditions, see https://econ-ark.github.io/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.
- Return type:
None
- class HARK.ConsumptionSaving.ConsIndShockModel.KinkedRconsumerType(**kwds)#
Bases:
IndShockConsumerType
A consumer type based on IndShockConsumerType, with different interest rates for saving (\(\mathsf{R}_{save}\)) and borrowing (\(\mathsf{R}_{boro}\)).
Solver for this class is currently only compatible with linear spline interpolation.
\[\begin{split}\newcommand{\CRRA}{\rho} \newcommand{\DiePrb}{\mathsf{D}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \begin{align*} v_t(m_t) &= \max_{c_t} u(c_t) + \DiscFac (1-\DiePrb_{t+1}) \mathbb{E}_{t} \left[(\PermGroFac_{t+1}\psi_{t+1})^{1-\CRRA} v_{t+1}(m_{t+1}) \right], \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= \Rfree_t/(\PermGroFac_{t+1} \psi_{t+1}) a_t + \theta_{t+1}, \\ \Rfree_t &= \begin{cases} \Rfree_{boro} & \text{if } a_t < 0\\ \Rfree_{save} & \text{if } a_t \geq 0, \end{cases}\\ \Rfree_{boro} &> \Rfree_{save}, \\ (\psi_{t+1},\theta_{t+1}) &\sim F_{t+1}, \\ \mathbb{E}[\psi]=\mathbb{E}[\theta] &= 1.\\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \\ \end{align*}\end{split}\]- Constructors:
IncShkDstn (Constructor, \(\psi\), \(\theta\)) – The agent’s income shock distributions.
It’s default constructor is
HARK.Calibration.Income.IncomeProcesses.construct_lognormal_income_process_unemployment()
aXtraGrid (Constructor) – The agent’s asset grid.
It’s default constructor is
HARK.utilities.make_assets_grid()
- Solving Parameters:
cycles (int) – 0 specifies an infinite horizon model, 1 specifies a finite model.
T_cycle (int) – Number of periods in the cycle for this agent type.
CRRA (float, \(\rho\)) – Coefficient of Relative Risk Aversion.
Rboro (float, \(\mathsf{R}_{boro}\)) – Risk Free interest rate when assets are negative.
Rsave (float, \(\mathsf{R}_{save}\)) – Risk Free interest rate when assets are positive.
DiscFac (float, \(\beta\)) – Intertemporal discount factor.
LivPrb (list[float], time varying, \(1-\mathsf{D}\)) – Survival probability after each period.
PermGroFac (list[float], time varying, \(\Gamma\)) – Permanent income growth factor.
BoroCnstArt (float, \(\underline{a}\)) – The minimum Asset/Perminant Income ratio, None to ignore.
vFuncBool (bool) – Whether to calculate the value function during solution.
CubicBool (bool) – Whether to use cubic spline interpoliation.
- Simulation Parameters:
AgentCount (int) – Number of agents of this kind that are created during simulations.
T_age (int) – Age after which to automatically kill agents, None to ignore.
T_sim (int, required for simulation) – Number of periods to simulate.
track_vars (list[strings]) – List of variables that should be tracked when running the simulation. For this agent, the options are ‘PermShk’, ‘TranShk’, ‘aLvl’, ‘aNrm’, ‘bNrm’, ‘cNrm’, ‘mNrm’, ‘pLvl’, and ‘who_dies’.
PermShk is the agent’s permanent income shock
TranShk is the agent’s transitory income shock
aLvl is the nominal asset level
aNrm is the normalized assets
bNrm is the normalized resources without this period’s labor income
cNrm is the normalized consumption
mNrm is the normalized market resources
pLvl is the permanent income level
who_dies is the array of which agents died
aNrmInitMean (float) – Mean of Log initial Normalized Assets.
aNrmInitStd (float) – Std of Log initial Normalized Assets.
pLvlInitMean (float) – Mean of Log initial permanent income.
pLvlInitStd (float) – Std of Log initial permanent income.
PermGroFacAgg (float) – Aggregate permanent income growth factor (The portion of PermGroFac attributable to aggregate productivity growth).
PerfMITShk (boolean) – Do Perfect Foresight MIT Shock (Forces Newborns to follow solution path of the agent they replaced if True).
NewbornTransShk (boolean) – Whether Newborns have transitory shock.
- Attributes:
solution (list[Consumer solution object]) – Created by the
solve()
method. Finite horizon models create a list with T_cycle+1 elements, for each period in the solution. Infinite horizon solutions return a list with T_cycle elements for each period in the cycle.Visit
HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution
for more information about the solution.history (Dict[Array]) – Created by running the
simulate()
method. Contains the variables in track_vars. Each item in the dictionary is an array with the shape (T_sim,AgentCount). VisitHARK.core.AgentType.simulate
for more information.
- IncShkDstn_defaults = {'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005}#
- aXtraGrid_defualts = {'aXtraCount': 48, 'aXtraExtra': None, 'aXtraMax': 20, 'aXtraMin': 0.001, 'aXtraNestFac': 3}#
- solving_defaults = {'BoroCnstArt': None, 'CRRA': 2.0, 'CubicBool': False, 'DiscFac': 0.96, 'LivPrb': [0.98], 'PermGroFac': [1.01], 'Rboro': 1.2, 'Rsave': 1.02, 'T_cycle': 1, 'constructors': {'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'solution_terminal': <function make_basic_CRRA_solution_terminal>}, 'cycles': 1, 'vFuncBool': False}#
- simulation_defualts = {'AgentCount': 10000, 'NewbornTransShk': False, 'PerfMITShk': False, 'PermGroFacAgg': 1.0, 'T_age': None, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'neutral_measure': False, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.0}#
- time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'Rboro', 'Rsave']#
- 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. This version deals with the different interest rates on borrowing vs saving.
- 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.
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.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.
- get_Rfree()#
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
- check_conditions(verbose)#
This empty method overwrites the version inherited from its parent class, IndShockConsumerType. The condition checks are not appropriate when Rfree has multiple values.
- Parameters:
None
- Return type:
None