ConsHabitModel#
This module has consumption-models with habit formation. Right now, it only has a single basic model with permanent and transitory income shocks, one risk-free asset, and a habit stock that evolves as a weighted average of current consumption and the prior habit stock.
- HARK.ConsumptionSaving.ConsHabitModel.make_lognormal_habit_init_dstn(hLogInitMean, hLogInitStd, HabitInitCount, RNG)#
Construct a lognormal distribution for (normalized) initial habit stock of newborns, hNrm. This is the default constructor for HabitInitDstn.
- Parameters:
- Returns:
HabitInitDstn – Discretized distribution of initial habit stock for newborns.
- Return type:
- class HARK.ConsumptionSaving.ConsHabitModel.HabitFormationInverter(CRRA, HabitRte, HabitWgt, ChiMax, ChiCount, ChiOrder, HabitMax, HabitCount, HabitOrder)#
Bases:
objectA class for solving the first order conditions of a consumption-saving model with habit formation. In this notation, HabitRte is a parameter on the unit interval representing how fast the habit stock evolves; a value of zero means no habit dynamics and a value of one means that H_t = c_t, complete updating. HabitWgt is also on the unit interval and represents the exponent on the habit stock, which is used as a divisor on consumption in the utility function.
Instances of this class take two arguments when called as a function: end-of- period habit stock H and transformed end-of-period marginal value chi.
chi = (W_a(a,H) - lambda * W_H(a,H)) ** (-1/rho)
a = m - c H = lambda * c + (1-lambda) * h m’ = R a / psi + theta h’ = H / psi
- Parameters:
CRRA (float) – Coefficient of relative risk aversion, rho.
HabitRte (float) – Rate of habit stock updating with new consumption, lambda. Must be greater than zero but less than one.
HabitWgt (float) – Weight of habit stock in preferences; exponent on habits as a divisior in utility function. Must be greater than zero but less than one.
ChiMax (float) – Largest value of “transformed marginal value” to consider in the grid. The minimum value is always zero. These chi values are “consumption-like”.
ChiCount (int) – Number of gridpoints in the “transformed marginal value” grid.
ChiOrder (float) – Strictly positive exponential order for the “transformed marginal value” grid.
HabitMax (float) – Largest value in the habit grid to consider; minimum is always zero.
HabitCount (int) – Number of gridpoints in the habit stock grid.
HabitOrder (float) – Strictly positive exponential order for the habit stock grid.
- cFunc(H, chi)#
- HARK.ConsumptionSaving.ConsHabitModel.make_inverter(CRRA, HabitRte, HabitWgt, ChiMax, ChiCount, ChiOrder, HabitMax, HabitCount, HabitOrder)#
- HARK.ConsumptionSaving.ConsHabitModel.make_habit_grid(HabitMin, HabitMax, HabitCount, HabitOrder)#
- HARK.ConsumptionSaving.ConsHabitModel.make_habit_solution_terminal()#
Make a pseudo-terminal solution for the habit formation model, which has zero functions for (marginal) value.
- HARK.ConsumptionSaving.ConsHabitModel.calc_marg_values(S, k, hpre, rho, R, Gamma, alpha, lamda, beta, C, Vp)#
Helper function for computing expected marginal value with respect to market resources and habit stock. Used internally by solve_one_period_ConsHabit.
The code here uses “math notation” for quick programming. See the only place in the code where this function is used for a translation of the symbols.
- HARK.ConsumptionSaving.ConsHabitModel.solve_one_period_ConsHabit(solution_next, IncShkDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, HabitGrid, FOCinverter, HabitWgt, HabitRte)#
Solve one period of the consumption-saving model with habit formation.
- Parameters:
solution_next (dict) – Dictionary with next period’s solution.
IncShkDstn (DiscreteDistribution) – Discretized permanent and transitory income shock distribution this period.
LivPrb (float) – Survival probability at the end of this period.
DiscFac (float) – Intertemporal discount factor.
CRRA (float) – Coefficient of relative risk aversion.
Rfree (float) – Interest factor on capital at the start of this period.
PermGroFac (float) – Permanent income growth factor at the start of this period.
BoroCnstArt (float or None) – Artificial borrowing constraint on assets at the end of this period, as a fraction of permanent income.
aXtraGrid (np.array) – Grid of “assets above minimum”.
HabitGrid (np.array) – Grid of consumption habit stocks on which to solve the problem.
FOCinverter (HabitFormationInverter) – Function that inverts the first order conditions to yield optimal consumption and the decision-time habit stock from which it was chosen.
HabitWgt (float) – Exponent on habit stock, which is used as a divisor on consumption in the utility function: U(c,h) = u(c / h**alpha). Should be on unit interval.
HabitRte (float) – Rate at which habit stock is updated by new consumption: H = lambda*c + (1-lambda)*h. Should be on the unit interval.
- Returns:
solution_now – Solution to this period’s problem, with the following keys: cFunc : Consumption function over (mNrm, hNrm). dvdkFunc : Marginal value of beginning-of-period capital, defined on (kNrm, hPre). dvdhFunc : Marginal value of beginning-of-period habit stock, defined on (kNrm, hPre). kNrmMin : Minimum allowable beginning-of-period capital.
- Return type:
- class HARK.ConsumptionSaving.ConsHabitModel.HabitConsumerType(solution_terminal=None, pseudo_terminal=True, tolerance=1e-06, verbose=1, quiet=False, seed=0, construct=True, use_defaults=True, **kwds)#
Bases:
AgentTypeA class for representing consumers who form consumption habits. Agents get flow utility according to a CRRA felicity function that depends on both current consumption and the habit stock h_t. The habit stock evolves as a weighted average of current consumption and prior habit stock. Consumers can save in a single risk-free asset, so this model is an extension of the workhorse IndShockConsumerType to include a habit stock.
\[ \begin{align}\begin{aligned}\newcommand{\CRRA}{\rho} \newcommand{\LivPrb}{\mathsf{S}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \newcommand{\HabitWgt}{\alpha} \newcommand{\HabitRte}{\lambda}\\\begin{split}\begin{align*} v_t(m_t,h_t) &= \max_{c_t}u(c_t,h_t) + \DiscFac \LivPrb_t \mathbb{E}_{t} \left[ (\PermGroFac_{t+1} \psi_{t+1})^{(1-\HabitWgt)(1-\CRRA)} v_{t+1}(m_{t+1}, h_{t+1}) \right], \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ H_t &= \HabitRte c_t + (1-\HabitRte) h_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= a_t \Rfree_{t+1}/(\PermGroFac_{t+1} \psi_{t+1}) + \theta_{t+1}, \\ h_{t+1} &= H_t / (\PermGroFac_{t+1} \psi_{t+1}), \\ (\psi_{t+1},\theta_{t+1}) &\sim F_{t+1}, \\ \mathbb{E}[\psi] &= 1, \\ u(c,h) &= \frac{(c/h^\HabitWgt)^{1-\CRRA}}{1-\CRRA}. \end{align*}\end{split}\end{aligned}\end{align} \]- default_ = {'model': 'ConsHabit.yaml', 'params': {'AgentCount': 10000, 'BoroCnstArt': 0.0, 'CRRA': 2.0, 'ChiCount': 251, 'ChiMax': 50.0, 'ChiOrder': 1.5, 'DiscFac': 0.96, 'HabitCount': 51, 'HabitInitCount': 15, 'HabitMax': 5.0, 'HabitMin': 0.2, 'HabitOrder': 1.5, 'HabitRte': 0.2, 'HabitWgt': 0.5, 'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'LivPrb': [0.98], 'PermGroFac': [1.01], 'PermShkCount': 7, 'PermShkStd': [0.1], 'Rfree': [1.03], 'T_age': None, 'T_cycle': 1, 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005, 'aXtraCount': 48, 'aXtraExtra': None, 'aXtraMax': 20, 'aXtraMin': 0.001, 'aXtraNestFac': 2, 'constructors': {'FOCinverter': <function make_inverter>, 'HabitGrid': <function make_habit_grid>, 'HabitInitDstn': <function make_lognormal_habit_init_dstn>, 'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'kNrmInitDstn': <function make_lognormal_kNrm_init_dstn>, 'pLvlInitDstn': <function make_lognormal_pLvl_init_dstn>, 'solution_terminal': <function make_habit_solution_terminal>}, 'cycles': 1, 'hLogInitMean': -0.5, 'hLogInitStd': 0.2, 'kLogInitMean': -12.0, 'kLogInitStd': 0.0, 'kNrmInitCount': 15, 'pLogInitMean': 0.0, 'pLogInitStd': 0.0, 'pLvlInitCount': 15, 'pseudo_terminal': True}, 'solver': <function solve_one_period_ConsHabit>, 'track_vars': ['aNrm', 'cNrm', 'mNrm', 'hNrm', 'pLvl']}#
- time_inv_ = ['DiscFac', 'CRRA', 'BoroCnstArt', 'aXtraGrid', 'HabitGrid', 'FOCinverter', 'HabitWgt', 'HabitRte']#
- time_vary_ = ['IncShkDstn', 'Rfree', 'PermGroFac', 'LivPrb']#
- shock_vars_ = ['PermShk', 'TranShk']#
- distributions = ['IncShkDstn', 'PermShkDstn', 'TranShkDstn', 'kNrmInitDstn', 'pLvlInitDstn', 'HabitInitDstn']#