ConsMedModel#

Consumption-saving models that also include medical spending.

class HARK.ConsumptionSaving.ConsMedModel.MedShockPolicyFunc(xFunc, xLvlGrid, MedShkGrid, MedPrice, CRRAcon, CRRAmed, xLvlCubicBool=False, MedShkCubicBool=False)#

Bases: MetricObject

Class for representing the policy function in the medical shocks model: opt- imal consumption and medical care for given market resources, permanent income, and medical need shock. Always obeys Con + MedPrice*Med = optimal spending.

Parameters:
  • xFunc (function) – Optimal total spending as a function of market resources, permanent income, and the medical need shock.

  • xLvlGrid (np.array) – 1D array of total expenditure levels.

  • MedShkGrid (np.array) – 1D array of medical shocks.

  • MedPrice (float) – Relative price of a unit of medical care.

  • CRRAcon (float) – Coefficient of relative risk aversion for consumption.

  • CRRAmed (float) – Coefficient of relative risk aversion for medical care.

  • xLvlCubicBool (boolean) – Indicator for whether cubic spline interpolation (rather than linear) should be used in the xLvl dimension.

  • MedShkCubicBool (boolean) – Indicator for whether bicubic interpolation should be used; only operative when xLvlCubicBool=True.

distance_criteria = ['xFunc', 'cFunc', 'MedPrice']#
derivativeX(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to market resources at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

  • dcdm (np.array) – Derivative of consumption with respect to market resources for each point in (xLvl,MedShk).

  • dMeddm (np.array) – Derivative of medical care with respect to market resources for each point in (xLvl,MedShk).

derivativeY(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to permanent income at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

  • dcdp (np.array) – Derivative of consumption with respect to permanent income for each point in (xLvl,MedShk).

  • dMeddp (np.array) – Derivative of medical care with respect to permanent income for each point in (xLvl,MedShk).

derivativeZ(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to medical need shock at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

  • dcdShk (np.array) – Derivative of consumption with respect to medical need for each point in (xLvl,MedShk).

  • dMeddShk (np.array) – Derivative of medical care with respect to medical need for each point in (xLvl,MedShk).

class HARK.ConsumptionSaving.ConsMedModel.cThruXfunc(xFunc, cFunc)#

Bases: MetricObject

Class for representing consumption function derived from total expenditure and consumption.

Parameters:
  • xFunc (function) – Optimal total spending as a function of market resources, permanent income, and the medical need shock.

  • cFunc (function) – Optimal consumption as a function of total spending and the medical need shock.

distance_criteria = ['xFunc', 'cFunc']#
derivativeX(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption with respect to market resources at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

dcdm – Derivative of consumption with respect to market resources for each point in (xLvl,MedShk).

Return type:

np.array

derivativeY(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to permanent income at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

dcdp – Derivative of consumption with respect to permanent income for each point in (xLvl,MedShk).

Return type:

np.array

derivativeZ(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to medical need shock at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

dcdShk – Derivative of consumption with respect to medical need for each point in (xLvl,MedShk).

Return type:

np.array

class HARK.ConsumptionSaving.ConsMedModel.MedThruXfunc(xFunc, cFunc, MedPrice)#

Bases: MetricObject

Class for representing medical care function derived from total expenditure and consumption.

Parameters:
  • xFunc (function) – Optimal total spending as a function of market resources, permanent income, and the medical need shock.

  • cFunc (function) – Optimal consumption as a function of total spending and the medical need shock.

  • MedPrice (float) – Relative price of a unit of medical care.

distance_criteria = ['xFunc', 'cFunc', 'MedPrice']#
derivativeX(mLvl, pLvl, MedShk)#

Evaluate the derivative of consumption and medical care with respect to market resources at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

  • dcdm (np.array) – Derivative of consumption with respect to market resources for each point in (xLvl,MedShk).

  • dMeddm (np.array) – Derivative of medical care with respect to market resources for each point in (xLvl,MedShk).

derivativeY(mLvl, pLvl, MedShk)#

Evaluate the derivative of medical care with respect to permanent income at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

dMeddp – Derivative of medical care with respect to permanent income for each point in (xLvl,MedShk).

Return type:

np.array

derivativeZ(mLvl, pLvl, MedShk)#

Evaluate the derivative of medical care with respect to medical need shock at given levels of market resources, permanent income, and medical need shocks.

Parameters:
  • mLvl (np.array) – Market resource levels.

  • pLvl (np.array) – Permanent income levels; should be same size as mLvl.

  • MedShk (np.array) – Medical need shocks; should be same size as mLvl.

Returns:

dMeddShk – Derivative of medical care with respect to medical need for each point in (xLvl,MedShk).

Return type:

np.array

class HARK.ConsumptionSaving.ConsMedModel.MedShockConsumerType(**kwds)#

Bases: PersistentShockConsumerType

A consumer type based on GenIncShockConsumerType, with two types of consumption goods (medical and nonmedical) and random shocks to medical utility.

\[\begin{split}\begin{eqnarray*} V_t(M_t,P_t, \text{medShk}_t) &=& \max_{C_t, med_t} U_t(C_t, med_t) + \beta (1-\mathsf{D}_{t+1}) \mathbb{E} [V_{t+1}(M_{t+1}, P_{t+1}, \text{medShk}_{t+1})], \\ A_t &=& M_t - X_t, \\ X_t &=& C_t +med_t \textbf{ medPrice}_t,\\ A_t/P_t &\geq& \underline{a}, \\ M_{t+1} &=& R A_t + \theta_{t+1}, \\ P_{t+1} &=& G_{t+1}(P_t)\psi_{t+1}, \\ (\psi_{t+1},\theta_{t+1},\text{medShk}_{t+1}) &\sim& F_{t+1}\\ U_t(C, med) &=& \frac{C^{1-\rho}}{1-\rho}+\text{ medShk}_t \frac{med^{1-\rho_{med}}}{1-\rho_{med}}. \end{eqnarray*}\end{split}\]
Constructors:
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.

  • CRRAmed (float, \(\rho_{med}\)) – Coefficient of Relative Risk Aversion on Medical Care

  • 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 ‘Med’, ‘MedShk’, ‘PermShk’, ‘TranShk’, ‘aLvl’, ‘cLvl’, ‘mLvl’, ‘pLvl’, and ‘who_dies’.

    PermShk is the agent’s permanent income shock

    MedShk is the agent’s medical utility shock

    TranShk is the agent’s transitory income shock

    aLvl is the nominal asset level

    cLvl is the nominal consumption level

    Med is the nominal medical spending level

    mLvl is the nominal 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.

    Unlike other models with this solution type, this model’s variables are NOT normalized. The solution functions additionally depend on the permanent income level and the medical shock. For example, \(C=\text{cFunc}(M,P,MedShk)\). hNrm has been replaced by hLvl which is a function of permanent income. MPC max has not yet been implemented for this class. It will be a function of permanent income.

    This solution has two additional functions \(\text{Med}=\text{MedFunc}(M,P,\text{MedShk})\): returns the agent’s spending on Medical care

    \([C,Med]=\text{policyFunc}(M,P,\text{MedShk})\): returns the agent’s spending on consumption and Medical care as numpy arrays

    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). Visit HARK.core.AgentType.simulate for more information.

default_params_ = {'AgentCount': 10000, 'BoroCnstArt': 0.0, 'CRRA': 2.0, 'CRRAmed': 3.0, 'CubicBool': False, 'DiscFac': 0.96, 'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'LivPrb': [0.98], 'MedPrice': [1.5], 'MedShkAvg': [0.001], 'MedShkCount': 5, 'MedShkCountTail': 15, 'MedShkStd': [5.0], 'NewbornTransShk': False, 'PerfMITShk': False, 'PermGroFac': [1.0], 'PermGroFacAgg': 1.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'PrstIncCorr': 0.98, 'Rfree': 1.03, 'T_age': None, 'T_cycle': 1, 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'aXtraCount': 32, 'aXtraExtra': [0.005, 0.01], 'aXtraMax': 30, 'aXtraMin': 0.001, 'aXtraNestFac': 3, 'constructors': {'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'MedShkDstn': <function make_lognormal_MedShkDstn>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'pLvlGrid': <function make_pLvlGrid_by_simulation>, 'pLvlNextFunc': <function make_AR1_style_pLvlNextFunc>, 'pLvlPctiles': <function make_basic_pLvlPctiles>, 'solution_terminal': <function make_MedShock_solution_terminal>}, 'cycles': 1, 'neutral_measure': False, 'pLvlExtra': [0.0001], 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.4, 'pLvlPctiles_bound': [0.05, 0.95], 'pLvlPctiles_count': 19, 'pLvlPctiles_tail_count': 4, 'pLvlPctiles_tail_order': 2.718281828459045, 'vFuncBool': False}#
shock_vars_ = ['PermShk', 'TranShk', 'MedShk']#
state_vars = ['pLvl', 'mLvl', 'aLvl', 'mLvl']#
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).

update()#

Update the income process, the assets grid, the permanent income grid, the medical shock distribution, and the terminal solution.

Parameters:

None

Return type:

None

update_med_shock_process()#

Constructs discrete distributions of medical preference shocks for each period in the cycle. Distributions are saved as attribute MedShkDstn, which is added to time_vary.

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 PersistentShockConsumerType.reset_rng() to also reset elements of MedShkDstn.

Parameters:

None

Return type:

None

get_shocks()#

Gets permanent and transitory income shocks for this period as well as medical need shocks and the price of medical care.

Parameters:

None

Return type:

None

get_controls()#

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

Parameters:

None

Return type:

None

get_poststates()#

Calculates end-of-period assets for each consumer of this type.

Parameters:

None

Return type:

None

HARK.ConsumptionSaving.ConsMedModel.make_lognormal_MedShkDstn(T_cycle, MedShkAvg, MedShkStd, MedShkCount, MedShkCountTail, RNG, MedShkTailBound=[0.0, 0.9])#

Constructs discretized lognormal distributions of medical preference shocks for each period in the cycle.

\[\begin{split}\text{ medShk}_t \sim \exp(\mathcal{N}(\textbf{MedShkStd}^2)) \\ \mathbb{E}[\text{medShk}_t]=\textbf{MedShkAvg}\end{split}\]
Parameters:
  • T_cycle (int) – Number of non-terminal periods in the agent’s cycle.

  • MedShkAvg ([float]) – Mean of medical needs shock in each period of the problem.

  • MedShkStd ([float]) – Standard deviation of log medical needs shock in each period of the problem.

  • MedShkCount (int) – Number of equiprobable nodes in the “body” of the discretization.

  • MedShkCountTail (int) – Number of nodes in each “tail” of the discretization.

  • RNG (RandomState) – The AgentType’s internal random number generator.

  • MedShkTailBound ([float,float]) – CDF bounds for the tail of the discretization.

Returns:

MedShkDstn

Return type:

[DiscreteDistribuion]