ConsPortfolioModel#

This file contains classes and functions for representing, solving, and simulating agents who must allocate their resources among consumption, saving in a risk-free asset (with a low return), and saving in a risky asset (with higher average return).

class HARK.ConsumptionSaving.ConsPortfolioModel.PortfolioConsumerType(verbose=False, quiet=False, **kwds)#

Bases: IndShockRiskyAssetConsumerType

A consumer type with a portfolio choice. This agent type has log-normal return factors. Their problem is defined by a coefficient of relative risk aversion, intertemporal discount factor, risk-free interest factor, and time sequences of permanent income growth rate, survival probability, and permanent and transitory income shock standard deviations (in logs). The agent may also invest in a risky asset, which has a higher average return than the risk-free asset. He might have age-varying beliefs about the risky-return; if he does, then “true” values of the risky asset’s return distribution must also be specified.

get_controls()#

Calculates consumption cNrmNow and risky portfolio share ShareNow using the policy functions in the attribute solution. These are stored as attributes.

Parameters:

None

Return type:

None

initialize_sim()#

Initialize the state of simulation attributes. Simply calls the same method for IndShockConsumerType, then sets the type of AdjustNow to bool.

Parameters:

None

Return type:

None

sim_birth(which_agents)#

Create new agents to replace ones who have recently died; takes draws of initial aNrm and pLvl, as in ConsIndShockModel, then sets Share and Adjust to zero as initial values. :param which_agents: Boolean array of size AgentCount indicating which agents should be “born”. :type which_agents: np.array

Return type:

None

time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'PortfolioBisect', 'AdjustPrb', 'DiscreteShareBool']#
update()#

Update the income process, the assets grid, and the terminal solution.

Parameters:

None

Return type:

None

update_solution_terminal()#

Solves the terminal period of the portfolio choice problem. The solution is trivial, as usual: consume all market resources, and put nothing in the risky asset (because you have nothing anyway).

Parameters:

None

Return type:

None

class HARK.ConsumptionSaving.ConsPortfolioModel.PortfolioSolution(cFuncAdj=None, ShareFuncAdj=None, vFuncAdj=None, vPfuncAdj=None, cFuncFxd=None, ShareFuncFxd=None, vFuncFxd=None, dvdmFuncFxd=None, dvdsFuncFxd=None, aGrid=None, Share_adj=None, EndOfPrddvda_adj=None, ShareGrid=None, EndOfPrddvda_fxd=None, EndOfPrddvds_fxd=None, AdjPrb=None)#

Bases: MetricObject

A class for representing the single period solution of the portfolio choice model.

Parameters:
  • cFuncAdj (Interp1D) – Consumption function over normalized market resources when the agent is able to adjust their portfolio shares.

  • ShareFuncAdj (Interp1D) – Risky share function over normalized market resources when the agent is able to adjust their portfolio shares.

  • vFuncAdj (ValueFuncCRRA) – Value function over normalized market resources when the agent is able to adjust their portfolio shares.

  • vPfuncAdj (MargValueFuncCRRA) – Marginal value function over normalized market resources when the agent is able to adjust their portfolio shares.

  • cFuncFxd (Interp2D) – Consumption function over normalized market resources and risky portfolio share when the agent is NOT able to adjust their portfolio shares, so they are fixed.

  • ShareFuncFxd (Interp2D) – Risky share function over normalized market resources and risky portfolio share when the agent is NOT able to adjust their portfolio shares, so they are fixed. This should always be an IdentityFunc, by definition.

  • vFuncFxd (ValueFuncCRRA) – Value function over normalized market resources and risky portfolio share when the agent is NOT able to adjust their portfolio shares, so they are fixed.

  • dvdmFuncFxd (MargValueFuncCRRA) – Marginal value of mNrm function over normalized market resources and risky portfolio share when the agent is NOT able to adjust their portfolio shares, so they are fixed.

  • dvdsFuncFxd (MargValueFuncCRRA) – Marginal value of Share function over normalized market resources and risky portfolio share when the agent is NOT able to adjust their portfolio shares, so they are fixed.

  • aGrid (np.array) – End-of-period-assets grid used to find the solution.

  • Share_adj (np.array) – Optimal portfolio share associated with each aGrid point.

  • EndOfPrddvda_adj (np.array) – Marginal value of end-of-period resources associated with each aGrid point.

  • ShareGrid (np.array) – Grid for the portfolio share that is used to solve the model.

  • EndOfPrddvda_fxd (np.array) – Marginal value of end-of-period resources associated with each (aGrid x sharegrid) combination, for the agent who can not adjust his portfolio.

  • AdjustPrb (float) – Probability that the agent will be able to adjust his portfolio next period.

distance_criteria = ['vPfuncAdj']#
HARK.ConsumptionSaving.ConsPortfolioModel.calc_dvdm_next(shocks, b_nrm, share, adjust_prob, perm_gro_fac, crra, vp_func_adj, dvdm_func_fxd)#

Evaluate realizations of marginal value of market resources next period, based on the income distribution “shocks”, values of bank balances bNrm, and values of the risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_dvds_next(shocks, b_nrm, share, adjust_prob, perm_gro_fac, crra, dvds_func_fxd)#

Evaluate realizations of marginal value of risky share next period, based on the income distribution “shocks”, values of bank balances bNrm, and values of the risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_dvdx_next(shocks, b_nrm, share, adjust_prob, perm_gro_fac, crra, vp_func_adj, dvdm_func_fxd, dvds_func_fxd)#

Evaluate realizations of marginal values next period, based on the income distribution “shocks”, values of bank balances bNrm, and values of the risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_dvda(shocks, a_nrm, share, rfree, dvdb_func)#

Compute end-of-period marginal value of assets at values a, conditional on risky asset return shocks and risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_dvds(shocks, a_nrm, share, rfree, dvdb_func, dvds_func)#

Compute end-of-period marginal value of risky share at values a, conditional on risky asset return shocks and risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_dvdx(shocks, a_nrm, share, rfree, dvdb_func, dvds_func)#

Compute end-of-period marginal values at values a, conditional on risky asset return shocks and risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_dvdx_joint(shocks, a_nrm, share, rfree, adjust_prob, perm_gro_fac, crra, vp_func_adj, dvdm_func_fxd, dvds_func_fxd)#

Evaluate end-of-period marginal value of assets and risky share based on the shock distribution S, values of bend of period assets a, and risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_v(shocks, a_nrm, share, rfree, v_func)#

Compute end-of-period values.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_end_of_prd_v_joint(shocks, a_nrm, share, rfree, adjust_prob, perm_gro_fac, crra, v_func_adj, v_func_fxd)#

Evaluate end-of-period value, based on the shock distribution S, values of bank balances bNrm, and values of the risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_human_wealth(shocks, perm_gro_fac, share_limit, rfree, crra, h_nrm_next)#

Calculate human wealth this period given human wealth next period.

Parameters:
  • shocks (DiscreteDistribution) – Joint distribution of shocks to income and returns.

  • perm_gro_fac (float) – Permanent income growth factor

  • share_limit (float) – limiting lower bound of risky portfolio share

  • rfree (float) – Risk free interest rate

  • crra (float) – Coefficient of relative risk aversion

  • h_nrm_next (float) – Human wealth next period

HARK.ConsumptionSaving.ConsPortfolioModel.calc_m_nrm_next(shocks, b_nrm, perm_gro_fac)#

Calculate future realizations of market resources mNrm from the income shock distribution “shocks” and normalized bank balances b.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_m_nrm_next_joint(shocks, a_nrm, share, rfree, perm_gro_fac)#

Calculate future realizations of market resources mNrm from the shock distribution shocks, normalized end-of-period assets a, and risky share z.

HARK.ConsumptionSaving.ConsPortfolioModel.calc_radj(shock, share_limit, rfree, crra)#

Expected rate of return adjusted by CRRA

Parameters:
  • shock (DiscreteDistribution) – Distribution of risky asset returns

  • share_limit (float) – limiting lower bound of risky portfolio share

  • rfree (float) – Risk free interest rate

  • crra (float) – Coefficient of relative risk aversion

HARK.ConsumptionSaving.ConsPortfolioModel.calc_v_intermed(shocks, b_nrm, share, adjust_prob, perm_gro_fac, crra, v_func_adj, v_func_fxd)#

Calculate “intermediate” value from next period’s bank balances, the income shocks shocks, and the risky asset share.

HARK.ConsumptionSaving.ConsPortfolioModel.solve_one_period_ConsPortfolio(solution_next, ShockDstn, IncShkDstn, RiskyDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, ShareGrid, AdjustPrb, ShareLimit, vFuncBool, DiscreteShareBool, IndepDstnBool)#

Solve one period of a consumption-saving problem with portfolio allocation between a riskless and risky asset. This function handles various sub-cases or variations on the problem, including the possibility that the agent does not necessarily get to update their portfolio share in every period, or that they must choose a discrete rather than continuous risky share.

Parameters:
  • solution_next (PortfolioSolution) – Solution to next period’s problem.

  • ShockDstn (Distribution) – Joint distribution of permanent income shocks, transitory income shocks, and risky returns. This is only used if the input IndepDstnBool is False, indicating that income and return distributions can’t be assumed to be independent.

  • IncShkDstn (Distribution) – Discrete distribution of permanent income shocks and transitory income shocks. This is only used if the input IndepDstnBool is True, indicating that income and return distributions are independent.

  • RiskyDstn (Distribution) – Distribution of risky asset returns. This is only used if the input IndepDstnBool is True, indicating that income and return distributions are independent.

  • 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.

  • Rfree (float) – Risk free interest factor on end-of-period assets.

  • PermGroFac (float) – Expected permanent income growth factor at the end of this period.

  • BoroCnstArt (float or None) – Borrowing constraint for the minimum allowable assets to end the period with. In this model, it is required to be zero.

  • aXtraGrid (np.array) – Array of “extra” end-of-period asset values– assets above the absolute minimum acceptable level.

  • ShareGrid (np.array) – Array of risky portfolio shares on which to define the interpolation of the consumption function when Share is fixed. Also used when the risky share choice is specified as discrete rather than continuous.

  • AdjustPrb (float) – Probability that the agent will be able to update his portfolio share.

  • ShareLimit (float) – Limiting lower bound of risky portfolio share as mNrm approaches infinity.

  • vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.

  • DiscreteShareBool (bool) – Indicator for whether risky portfolio share should be optimized on the continuous [0,1] interval using the FOC (False), or instead only selected from the discrete set of values in ShareGrid (True). If True, then vFuncBool must also be True.

  • IndepDstnBool (bool) – Indicator for whether the income and risky return distributions are in- dependent of each other, which can speed up the expectations step.

Returns:

solution_now – Solution to this period’s problem.

Return type:

PortfolioSolution