HARK.ConsumptionSaving.ConsMedModel

Consumption-saving models that also include medical spending.

class HARK.ConsumptionSaving.ConsMedModel.ConsMedShockSolver(solution_next, IncomeDstn, MedShkDstn, LivPrb, DiscFac, CRRA, CRRAmed, Rfree, MedPrice, pLvlNextFunc, BoroCnstArt, aXtraGrid, pLvlGrid, vFuncBool, CubicBool)

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.

addvPPfunc(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
defBoroCnst(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
defUtilityFuncs()

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
getPointsForInterpolation(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.

makeBasicSolution(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

makeCubicxFunc(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

makeLinearxFunc(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

makevAndvPfuncs(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.
setAndUpdateValues(solution_next, IncomeDstn, 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.
  • IncomeDstn ([np.array]) – A list containing three arrays of floats, representing a discrete approximation to the income process between the period being solved and the one immediately following (in solution_next). Order: event probabilities, permanent shocks, transitory shocks.
  • 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
usePointsForInterpolation(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

class HARK.ConsumptionSaving.ConsMedModel.MedShockConsumerType(cycles=0, time_flow=True, **kwds)

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.

getControls()

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

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

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

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

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
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
updateMedShockProcess()

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
updateSolutionTerminal()

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
updatepLvlGrid()

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
class HARK.ConsumptionSaving.ConsMedModel.MedShockPolicyFunc(xFunc, xLvlGrid, MedShkGrid, MedPrice, CRRAcon, CRRAmed, xLvlCubicBool=False, MedShkCubicBool=False)

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.

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.MedThruXfunc(xFunc, cFunc, MedPrice)

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

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.cThruXfunc(xFunc, cFunc)

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

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

HARK.ConsumptionSaving.ConsMedModel.solveConsMedShock(solution_next, IncomeDstn, MedShkDstn, LivPrb, DiscFac, CRRA, CRRAmed, Rfree, MedPrice, pLvlNextFunc, BoroCnstArt, aXtraGrid, pLvlGrid, vFuncBool, CubicBool)

Solve the one period problem for a consumer with shocks to permanent and transitory income as well as medical need shocks (as multiplicative shifters for utility from a second medical care good).

Parameters:
  • solution_next (ConsumerSolution) – The solution to next period’s one period problem.
  • IncomeDstn ([np.array]) – A list containing three arrays of floats, representing a discrete approximation to the income process between the period being solved and the one immediately following (in solution_next). Order: event probabilities, permanent shocks, transitory shocks.
  • MedShkDstn ([np.array]) – Discrete distribution of the multiplicative utility shifter for med- ical care. Order: probabilities, preference shocks.
  • 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.
  • PrstIncCorr (float) – Correlation of permanent income from period to period.
  • 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.
Returns:

solution – Solution to this period’s problem, including a consumption function, medical spending function, and marginal value function. The former two are defined over (mLvl,pLvl,MedShk), while the latter is defined only on (mLvl,pLvl), with MedShk integrated out.

Return type:

ConsumerSolution