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: HARK.core.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.
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).

distance_criteria = ['xFunc', 'cFunc', 'MedPrice']
class HARK.ConsumptionSaving.ConsMedModel.cThruXfunc(xFunc, cFunc)

Bases: HARK.core.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.
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

distance_criteria = ['xFunc', 'cFunc']
class HARK.ConsumptionSaving.ConsMedModel.MedThruXfunc(xFunc, cFunc, MedPrice)

Bases: HARK.core.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.
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

distance_criteria = ['xFunc', 'cFunc', 'MedPrice']
class HARK.ConsumptionSaving.ConsMedModel.MedShockConsumerType(cycles=0, **kwds)

Bases: HARK.ConsumptionSaving.ConsGenIncProcessModel.PersistentShockConsumerType

A class to represent agents who consume two goods: ordinary composite consumption and medical care; both goods yield CRRAutility, and the coefficients on the goods might be different. Agents expect to receive shocks to permanent and transitory income as well as multiplicative shocks to utility from medical care.

See init_med_shock for a dictionary of the keywords that should be passed to the constructor.

Parameters:cycles (int) – Number of times the sequence of periods should be solved.
get_controls()

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

Parameters:None
Returns:
Return type:None
get_poststates()

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

Parameters:None
Returns:
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
Returns:
Return type:None
pre_solve()

A method that is run immediately before the model is solved, to check inputs or to prepare the terminal solution, perhaps.

Parameters:none
Returns:
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
Returns:
Return type:None
shock_vars_ = ['PermShk', 'TranShk', 'MedShk']
state_vars = ['pLvl', 'mLvl', 'aLvl', 'mLvl']
update()

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

Parameters:None
Returns:
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
Returns:
Return type:None
update_pLvlGrid()

Update the grid of permanent income levels. Currently only works for infinite horizon models (cycles=0) and lifecycle models (cycles=1). Not clear what to do about cycles>1. Identical to version in persistent shocks model, but pLvl=0 is manually added to the grid (because there is no closed form lower-bounding cFunc for pLvl=0).

Parameters:None
Returns:
Return type:None
update_solution_terminal()

Update the terminal period solution for this type. Similar to other models, optimal behavior involves spending all available market resources; however, the agent must split his resources between consumption and medical care.

Parameters:
  • None
  • Returns
  • --------
  • None
class HARK.ConsumptionSaving.ConsMedModel.ConsMedShockSolver(solution_next, IncShkDstn, MedShkDstn, LivPrb, DiscFac, CRRA, CRRAmed, Rfree, MedPrice, pLvlNextFunc, BoroCnstArt, aXtraGrid, pLvlGrid, vFuncBool, CubicBool)

Bases: HARK.ConsumptionSaving.ConsGenIncProcessModel.ConsGenIncProcessSolver

Class for solving the one period problem for the “medical shocks” model, in which consumers receive shocks to permanent and transitory income as well as shocks to “medical need”– multiplicative utility shocks for a second good.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncShkDstn (distribution.Distribution) – A discrete approximations to the income process between the period being solved and the one immediately following (in solution_next).
  • MedShkDstn (distribution.Distribution) – Discrete distribution of the multiplicative utility shifter for med- ical care.
  • LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period.
  • DiscFac (float) – Intertemporal discount factor for future utility.
  • CRRA (float) – Coefficient of relative risk aversion for composite consumption.
  • CRRAmed (float) – Coefficient of relative risk aversion for medical care.
  • Rfree (float) – Risk free interest factor on end-of-period assets.
  • MedPrice (float) – Price of unit of medical care relative to unit of consumption.
  • pLvlNextFunc (float) – Expected permanent income next period as a function of current pLvl.
  • BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with.
  • aXtraGrid (np.array) – Array of “extra” end-of-period (normalized) asset values– assets above the absolute minimum acceptable level.
  • pLvlGrid (np.array) – Array of permanent income levels at which to solve the problem.
  • vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.
  • CubicBool (boolean) – An indicator for whether the solver should use cubic or linear inter- polation.
add_vPPfunc(solution)

Adds the marginal marginal value function to an existing solution, so that the next solver can evaluate vPP and thus use cubic interpolation.

Parameters:solution (ConsumerSolution) – The solution to this single period problem, which must include the consumption function.
Returns:solution – The same solution passed as input, but with the marginal marginal value function for this period added as the attribute vPPfunc.
Return type:ConsumerSolution
def_BoroCnst(BoroCnstArt)

Defines the constrained portion of the consumption function as cFuncNowCnst, an attribute of self. Uses the artificial and natural borrowing constraints.

Parameters:BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable (normalized) assets to end the period with. If it is less than the natural borrowing constraint at a particular permanent income level, then it is irrelevant; BoroCnstArt=None indicates no artificial borrowing constraint.
Returns:
Return type:None
def_utility_funcs()

Defines CRRA utility function for this period (and its derivatives, and their inverses), saving them as attributes of self for other methods to use. Extends version from ConsIndShock models by also defining inverse marginal utility function over medical care.

Parameters:none
Returns:
Return type:none
get_points_for_interpolation(EndOfPrdvP, aLvlNow)

Finds endogenous interpolation points (x,m) for the expenditure function.

Parameters:
  • EndOfPrdvP (np.array) – Array of end-of-period marginal values.
  • aLvlNow (np.array) – Array of end-of-period asset values that yield the marginal values in EndOfPrdvP.
Returns:

  • x_for_interpolation (np.array) – Total expenditure points for interpolation.
  • m_for_interpolation (np.array) – Corresponding market resource points for interpolation.
  • p_for_interpolation (np.array) – Corresponding permanent income points for interpolation.

make_basic_solution(EndOfPrdvP, aLvl, interpolator)

Given end of period assets and end of period marginal value, construct the basic solution for this period.

Parameters:
  • EndOfPrdvP (np.array) – Array of end-of-period marginal values.
  • aLvl (np.array) – Array of end-of-period asset values that yield the marginal values in EndOfPrdvP.
  • interpolator (function) – A function that constructs and returns a consumption function.
Returns:

solution_now – The solution to this period’s consumption-saving problem, with a consumption function, marginal value function, and minimum m.

Return type:

ConsumerSolution

make_cubic_xFunc(mLvl, pLvl, MedShk, xLvl)

Constructs the (unconstrained) expenditure function for this period using bilinear interpolation (over permanent income and the medical shock) among an array of cubic interpolations over market resources.

Parameters:
  • mLvl (np.array) – Corresponding market resource points for interpolation.
  • pLvl (np.array) – Corresponding permanent income level points for interpolation.
  • MedShk (np.array) – Corresponding medical need shocks for interpolation.
  • xLvl (np.array) – Expenditure points for interpolation, corresponding to those in mLvl, pLvl, and MedShk.
Returns:

xFuncUnc – Unconstrained total expenditure function for this period.

Return type:

BilinearInterpOnInterp1D

make_linear_xFunc(mLvl, pLvl, MedShk, xLvl)

Constructs the (unconstrained) expenditure function for this period using bilinear interpolation (over permanent income and the medical shock) among an array of linear interpolations over market resources.

Parameters:
  • mLvl (np.array) – Corresponding market resource points for interpolation.
  • pLvl (np.array) – Corresponding permanent income level points for interpolation.
  • MedShk (np.array) – Corresponding medical need shocks for interpolation.
  • xLvl (np.array) – Expenditure points for interpolation, corresponding to those in mLvl, pLvl, and MedShk.
Returns:

xFuncUnc – Unconstrained total expenditure function for this period.

Return type:

BilinearInterpOnInterp1D

make_v_and_vP_funcs(policyFunc)

Constructs the marginal value function for this period.

Parameters:policyFunc (function) – Consumption and medical care function for this period, defined over market resources, permanent income level, and the medical need shock.
Returns:
  • vFunc (function) – Value function for this period, defined over market resources and permanent income.
  • vPfunc (function) – Marginal value (of market resources) function for this period, defined over market resources and permanent income.
set_and_update_values(solution_next, IncShkDstn, LivPrb, DiscFac)

Unpacks some of the inputs (and calculates simple objects based on them), storing the results in self for use by other methods. These include: income shocks and probabilities, medical shocks and probabilities, next period’s marginal value function (etc), the probability of getting the worst income shock next period, the patience factor, human wealth, and the bounding MPCs.

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncShkDstn (distribution.Distribution) – A discrete approximation to the income process between the period being solved and the one immediately following (in solution_next).
  • LivPrb (float) – Survival probability; likelihood of being alive at the beginning of the succeeding period.
  • DiscFac (float) – Intertemporal discount factor for future utility.
Returns:

Return type:

None

solve()

Solves a one period consumption saving problem with risky income and shocks to medical need.

Parameters:None
Returns:solution – The solution to the one period problem, including a consumption function, medical spending function ( both defined over market re- sources, permanent income, and medical shock), a marginal value func- tion (defined over market resources and permanent income), and human wealth as a function of permanent income.
Return type:ConsumerSolution
use_points_for_interpolation(xLvl, mLvl, pLvl, MedShk, interpolator)

Constructs a basic solution for this period, including the consumption function and marginal value function.

Parameters:
  • xLvl (np.array) – Total expenditure points for interpolation.
  • mLvl (np.array) – Corresponding market resource points for interpolation.
  • pLvl (np.array) – Corresponding permanent income level points for interpolation.
  • MedShk (np.array) – Corresponding medical need shocks for interpolation.
  • interpolator (function) – A function that constructs and returns a consumption function.
Returns:

solution_now – The solution to this period’s consumption-saving problem, with a consumption function, marginal value function, and minimum m.

Return type:

ConsumerSolution