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

class
HARK.ConsumptionSaving.ConsPortfolioModel.
ConsPortfolioDiscreteSolver
(solution_next, ShockDstn, IncShkDstn, RiskyDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, ShareGrid, vFuncBool, AdjustPrb, DiscreteShareBool, ShareLimit, IndepDstnBool)¶ Bases:
HARK.ConsumptionSaving.ConsPortfolioModel.ConsPortfolioSolver
Define an objectoriented one period solver. Solve the one period problem for a portfoliochoice consumer. This solver is used when the income and risky return shocks are independent and the allowed optimal share is discrete over a finite set of points in ShareGrid.
Construct the risky share function when the agent can adjust
Optimization of Share on the discrete set ShareGrid

solve
()¶ Solve the one period problem for a portfoliochoice consumer.
Returns:  solution_now (PortfolioSolution)
 The solution to the single period consumptionsaving with portfolio choice
 problem. Includes two consumption and risky share functions (one for when)
 the agent can adjust his portfolio share (Adj) and when he can’t (Fxd).

class
HARK.ConsumptionSaving.ConsPortfolioModel.
ConsPortfolioJointDistSolver
(solution_next, ShockDstn, IncShkDstn, RiskyDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, ShareGrid, vFuncBool, AdjustPrb, DiscreteShareBool, ShareLimit, IndepDstnBool)¶ Bases:
HARK.ConsumptionSaving.ConsPortfolioModel.ConsPortfolioDiscreteSolver
,HARK.ConsumptionSaving.ConsPortfolioModel.ConsPortfolioSolver
Define an objectoriented one period solver. Solve the one period problem for a portfoliochoice consumer. This solver is used when the income and risky return shocks are not independent. The optimal share can be continuous or discrete.

calc_EndOfPrdvP
()¶ Calculate endofperiod marginal value of assets and shares at each point in aNrm and ShareGrid. Does so by taking expectation of next period marginal values across income and risky return shocks.

m_nrm_next
(shocks, a_nrm, r_port)¶ Calculate future realizations of market resources

make_EndOfPrdvFunc
()¶ Construct the endofperiod value function for this period, storing it as an attribute of self for use by other methods.

prepare_to_calc_EndOfPrdvP
()¶ Prepare to calculate endofperiod marginal values by creating an array of market resources that the agent could have next period, considering the grid of endofperiod assets and the distribution of shocks he might experience next period.

r_port
(shocks, share)¶ Calculate future realizations of market resources

set_and_update_values
()¶ Unpacks some of the inputs (and calculates simple objects based on them), storing the results in self for use by other methods.

solve
()¶ Solve the one period problem for a portfoliochoice consumer.
Returns:  solution_now (PortfolioSolution)
 The solution to the single period consumptionsaving with portfolio choice
 problem. Includes two consumption and risky share functions (one for when)
 the agent can adjust his portfolio share (Adj) and when he can’t (Fxd).


class
HARK.ConsumptionSaving.ConsPortfolioModel.
ConsPortfolioSolver
(solution_next, ShockDstn, IncShkDstn, RiskyDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, ShareGrid, vFuncBool, AdjustPrb, DiscreteShareBool, ShareLimit, IndepDstnBool)¶ Bases:
HARK.core.MetricObject
Define an objectoriented one period solver. Solve the one period problem for a portfoliochoice consumer. This solver is used when the income and risky return shocks are independent and the allowed optimal share is continuous.
Parameters:  solution_next (PortfolioSolution) – Solution to next period’s problem.
 ShockDstn ([np.array]) – List with four arrays: discrete probabilities, 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.Distribution) – Discrete distribution of permanent income shocks and transitory income shocks. This is only used if the input IndepDsntBool is True, indicating that income and return distributions are independent.
 RiskyDstn ([np.array]) – List with two arrays: discrete probabilities and 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 endofperiod 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” endofperiod 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.
 vFuncBool (boolean) – An indicator for whether the value function should be computed and included in the reported solution.
 AdjustPrb (float) – Probability that the agent will be able to update his portfolio share.
 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.
 ShareLimit (float) – Limiting lower bound of risky portfolio share as mNrm approaches infinity.
 IndepDstnBool (bool) – Indicator for whether the income and risky return distributions are in dependent of each other, which can speed up the expectations step.

add_save_points
()¶

add_vFunc
()¶ Creates the value function for this period and adds it to the solution.

calc_EndOfPrdvP
()¶ Calculate endofperiod marginal value of assets and shares at each point in aNrm and ShareGrid. Does so by taking expectation of next period marginal values across income and risky return shocks.

def_utility_funcs
()¶ Define temporary functions for utility and its derivative and inverse

m_nrm_next
(shocks, b_nrm)¶ Calculate future realizations of market resources

make_EndOfPrdvFunc
()¶ Construct the endofperiod value function for this period, storing it as an attribute of self for use by other methods.
Construct the risky share function when the agent can adjust

make_basic_solution
()¶ Given end of period assets and end of period marginal values, construct the basic solution for this period.

make_porfolio_solution
()¶

make_vFunc
()¶ Creates the value functions for this period, defined over market resources m when agent can adjust his portfolio, and over market resources and fixed share when agent can not adjust his portfolio. self must have the attribute EndOfPrdvFunc in order to execute.
Optimization of Share on continuous interval [0,1]

prepare_to_calc_EndOfPrdvP
()¶ Prepare to calculate endofperiod marginal values by creating an array of market resources that the agent could have next period, considering the grid of endofperiod assets and the distribution of shocks he might experience next period.

prepare_to_solve
()¶ Perform preparatory work.

set_and_update_values
()¶ Unpacks some of the inputs (and calculates simple objects based on them), storing the results in self for use by other methods.

solve
()¶ Solve the one period problem for a portfoliochoice consumer.
Returns:  solution_now (PortfolioSolution)
 The solution to the single period consumptionsaving with portfolio choice
 problem. Includes two consumption and risky share functions (one for when)
 the agent can adjust his portfolio share (Adj) and when he can’t (Fxd).

class
HARK.ConsumptionSaving.ConsPortfolioModel.
PortfolioConsumerType
(verbose=False, quiet=False, **kwds)¶ Bases:
HARK.ConsumptionSaving.ConsRiskyAssetModel.RiskyAssetConsumerType
A consumer type with a portfolio choice. This agent type has lognormal return factors. Their problem is defined by a coefficient of relative risk aversion, intertemporal discount factor, riskfree 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 riskfree asset. He might have agevarying beliefs about the riskyreturn; if he does, then “true” values of the risky asset’s return distribution must also be specified.

get_Rfree
()¶ Calculates realized return factor for each agent, using the attributes Rfree, RiskyNow, and ShareNow. This method is a bit of a misnomer, as the return factor is not riskless, but would more accurately be labeled as Rport. However, this method makes the portfolio model compatible with its parent class.
Parameters: None – Returns: Rport – Array of size AgentCount with each simulated agent’s realized portfolio return factor. Will be used by get_states() to calculate mNrmNow, where it will be mislabeled as “Rfree”. Return type: np.array

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 – Returns: 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 – 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

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
Returns: Return type: None

time_inv_
= ['CRRA', 'Rfree', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'AdjustPrb', 'DiscreteShareBool']¶

update
()¶ Update the income process, the assets grid, and the terminal solution.
Parameters: None – Returns: Return type: None
Creates the attribute ShareGrid as an evenly spaced grid on [0.,1.], using the primitive parameter ShareCount.
Parameters: None – Returns: Return type: None
Creates the attribute ShareLimit, representing the limiting lower bound of risky portfolio share as mNrm goes to infinity.
Parameters: None – Returns: 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, AdjPrb=None)¶ Bases:
HARK.core.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) – Endofperiodassets 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 endofperiod 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 endofperiod 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']¶