ConsMedModel#

Consumption-saving models that also include medical spending.

class HARK.ConsumptionSaving.ConsMedModel.MedShockConsumerType(solution_terminal=None, pseudo_terminal=True, tolerance=1e-06, verbose=1, quiet=False, seed=0, construct=True, use_defaults=True, **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,\eta_t) &=& \max_{C_t, med_t} U_t(C_t, med_t; \eta_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}, \\ P_{t+1} &=& \Gamma_{t+1}(P_t)\psi_{t+1}, \\ Y_{t+1} &=& P_{t+1} \theta_{t+1} M_{t+1} &=& R A_t + Y_{t+1}, \\ (\psi_{t+1},\theta_{t+1}) &\sim& F_{t+1},\\ \eta_t &~\sim& G_t,\\ U_t(C, med; \eta) &=& \frac{C^{1-\rho}}{1-\rho} +\eta \frac{med^{1-\nu}}{1-\nu}. \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 for consumption.

  • CRRAmed (float, \(\nu\)) – Coefficient of Relative Risk Aversion for 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_ = {'model': 'ConsMedShock.yaml', 'params': {'AgentCount': 10000, 'BoroCnstArt': 0.0, 'CRRA': 2.0, 'CRRAmed': 5.0, 'CubicBool': False, 'DiscFac': 0.96, 'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'LivPrb': [0.99], 'MedPrice': [1.5], 'MedShift': [1e-08], 'MedShkAvg': [0.1], 'MedShkCount': 5, 'MedShkCountTail': 15, 'MedShkStd': [1.5], '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, '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>, 'kNrmInitDstn': <function make_lognormal_kNrm_init_dstn>, 'pLvlGrid': <function make_pLvlGrid_by_simulation>, 'pLvlInitDstn': <function make_lognormal_pLvl_init_dstn>, 'pLvlNextFunc': <function make_AR1_style_pLvlNextFunc>, 'pLvlPctiles': <function make_basic_pLvlPctiles>, 'qFunc': <function make_qFunc>, 'solution_terminal': <function make_MedShock_solution_terminal>}, 'cycles': 1, 'kLogInitMean': -6.0, 'kLogInitStd': 1.0, 'kNrmInitCount': 15, 'neutral_measure': False, 'pLogInitMean': 0.0, 'pLogInitStd': 0.4, 'pLvlExtra': [0.0001], 'pLvlInitCount': 15, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.4, 'pLvlPctiles_bound': [0.05, 0.95], 'pLvlPctiles_count': 19, 'pLvlPctiles_tail_count': 4, 'pLvlPctiles_tail_order': 2.718281828459045, 'pseudo_terminal': False, 'vFuncBool': False}, 'solver': <function solve_one_period_ConsMedShock>, 'track_vars': ['aLvl', 'cLvl', 'Med', 'mLvl', 'pLvl']}#
time_vary_ = ['LivPrb', 'PermGroFac', 'Rfree', 'IncShkDstn', 'PermShkDstn', 'TranShkDstn', 'pLvlNextFunc', 'pLvlGrid', 'MedPrice', 'MedShkDstn', 'MedShift']#
time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'aXtraGrid', 'CRRAmed', 'qFunc']#
shock_vars_ = ['PermShk', 'TranShk', 'MedShk']#
state_vars = ['kLvl', 'pLvl', 'mLvl', 'aLvl', 'aNrm', 'mLvl']#
distributions = ['IncShkDstn', 'PermShkDstn', 'TranShkDstn', 'kNrmInitDstn', 'pLvlInitDstn', 'MedShkDstn']#
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).

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

class HARK.ConsumptionSaving.ConsMedModel.MedExtMargConsumerType(solution_terminal=None, pseudo_terminal=True, tolerance=1e-06, verbose=1, quiet=False, seed=0, construct=True, use_defaults=True, **kwds)#

Bases: PersistentShockConsumerType

Class for representing agents in the extensive margin medical expense model. Such agents have labor income dynamics identical to the “general income process” model (permanent income is not normalized out), and also experience a medical shock with two components: medical cost and utility loss. They face a binary choice of whether to pay the cost or suffer the loss, then make a consumption- saving decision as normal. To simplify the computation, the joint distribution of medical shocks is specified as bivariate lognormal. This can be loosened to accommodate insurance contracts as mappings from total to out-of-pocket expenses. Can also be extended to include a health process.

\[\begin{split}\begin{eqnarray*} V_t(M_t,P_t) &=& \max_{C_t, D_t} U_t(C_t) - (1-D_t) \eta_t + \beta (1-\mathsf{D}_{t+1}) \mathbb{E} [V_{t+1}(M_{t+1}, P_{t+1}], \\ A_t &=& M_t - C_t - D_t med_t, \\ A_t/ &\geq& 0, \\ D_t &\in& \{0,1\}, \\ P_{t+1} &=& \Gamma_{t+1}(P_t)\psi_{t+1}, \\ Y_{t+1} &=& P_{t+1} \theta_{t+1} M_{t+1} &=& R A_t + Y_{t+1}, \\ (\psi_{t+1},\theta_{t+1}) &\sim& F_{t+1},\\ (med_t,\eta_t) &~\sim& G_t,\\ U_t(C) &=& \frac{C^{1-\rho}}{1-\rho}. \end{eqnarray*}\end{split}\]
default_ = {'model': 'ConsExtMargMed.yaml', 'params': {'AgentCount': 10000, 'BeqInt': 1.0, 'BeqMPC': 0.1, 'CRRA': 1.5, 'DiscFac': 0.96, 'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'LivPrb': [0.99], 'MedCorr': [0.3], 'MedCostBot': -3.1, 'MedCostCount': 84, 'MedCostLogMean': [-1.0], 'MedCostLogStd': [1.0], 'MedCostTop': 5.2, 'MedShkLogMean': [-2.0], 'MedShkLogStd': [1.5], 'NewbornTransShk': True, 'PermGroFac': [1.0], 'PermGroFacAgg': 1.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'PrstIncCorr': 0.98, 'Rfree': [1.02], 'T_age': None, 'T_cycle': 1, 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005, 'aXtraCount': 96, 'aXtraExtra': [0.005, 0.01], 'aXtraMax': 40.0, 'aXtraMin': 0.001, 'aXtraNestFac': 2, 'constructors': {'BeqFac': <HARK.utilities.get_it_from object>, 'BeqParamDict': <function reformat_bequest_motive>, 'BeqShift': <HARK.utilities.get_it_from object>, 'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'IncomeProcessDict': <function make_persistent_income_process_dict>, 'MedShockDstn': <function make_continuous_MedShockDstn>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aNrmGrid': <function make_assets_grid>, 'kLvlGrid': <function make_capital_grid>, 'kNrmInitDstn': <function make_lognormal_kNrm_init_dstn>, 'mNrmGrid': <function make_market_resources_grid>, 'pLogGrid': <HARK.utilities.get_it_from object>, 'pLogMrkvArray': <HARK.utilities.get_it_from object>, 'pLvlInitDstn': <function make_lognormal_pLvl_init_dstn>, 'pLvlMean': <HARK.utilities.get_it_from object>, 'pLvlNextFunc': <function make_AR1_style_pLvlNextFunc>, 'solution_terminal': <function make_MedExtMarg_solution_terminal>}, 'cycles': 1, 'kLogInitMean': -6.0, 'kLogInitStd': 1.0, 'kLvlCount': 250, 'kLvlMax': 200, 'kLvlMin': 0.0, 'kLvlOrder': 2.0, 'kNrmInitCount': 15, 'mNrmCount': 72, 'mNrmExtra': None, 'mNrmMax': 40.0, 'mNrmMin': 0.001, 'mNrmNestFac': 2, 'pLogCount': 45, 'pLogInitMean': 0.0, 'pLogInitStd': 0.4, 'pLogRange': 3.5, 'pLvlInitCount': 25}, 'solver': <function solve_one_period_ConsMedExtMarg>, 'track_vars': ['aLvl', 'cLvl', 'Med', 'mLvl', 'pLvl']}#
time_vary_ = ['Rfree', 'LivPrb', 'MedShkLogMean', 'MedShkLogStd', 'MedCostLogMean', 'MedCostLogStd', 'MedCorr', 'pLogGrid', 'pLvlMean', 'TranShkDstn', 'pLogMrkvArray', 'pLvlNextFunc', 'IncShkDstn', 'MedShockDstn']#
time_inv_ = ['DiscFac', 'CRRA', 'BeqFac', 'BeqShift', 'MedCostBot', 'MedCostTop', 'MedCostCount', 'aNrmGrid', 'mNrmGrid', 'kLvlGrid']#
shock_vars = ['PermShk', 'TranShk', 'MedShk', 'MedCost']#
get_shocks()#

Gets permanent and transitory income shocks for this period as well as medical need and cost shocks.

get_controls()#

Finds consumption for each agent, along with whether or not they get care.

get_poststates()#

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

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]

HARK.ConsumptionSaving.ConsMedModel.make_continuous_MedShockDstn(MedShkLogMean, MedShkLogStd, MedCostLogMean, MedCostLogStd, MedCorr, T_cycle, RNG)#

Construct a time-varying list of bivariate lognormals for the medical shocks distribution. This representation uses fully continuous distributions, with no discretization in either dimension.

Parameters:
  • MedShkLogMean ([float]) – Age-varying list of means of log medical needs (utility) shocks.

  • MedShkLogStd ([float]) – Age-varying list of standard deviations of log medical needs (utility) shocks.

  • MedCostLogMean ([float]) – Age-varying list of means of log medical expense shocks.

  • MedCostLogStd ([float]) – Age-varying list of standard deviations of log medical expense shocks..

  • MedCorr ([float]) – Age-varying correlation coefficient between log medical expenses and utility shocks.

  • T_cycle (int) – Number of periods in the agent’s sequence.

  • RNG (RandomState) – Random number generator for this type.

Returns:

MedShockDstn – Age-varying list of bivariate lognormal distributions, ordered as (MedCost,MedShk).

Return type:

[MultivariateLognormal]