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.
PortfolioConsumerType
(cycles=1, verbose=False, quiet=False, **kwds)¶ Bases:
HARK.ConsumptionSaving.ConsIndShockModel.IndShockConsumerType
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_Adjust
()¶ Sets the attribute AdjustNow as a boolean array of size AgentCount, indicating whether each agent is able to adjust their risky portfolio share this period. Uses the attribute AdjustPrb to draw from a Bernoulli distribution.
Parameters: None – Returns: Return type: None

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_Risky
()¶ Sets the shock RiskyNow as a single draw from a lognormal distribution. Uses the attributes RiskyAvgTrue and RiskyStdTrue if RiskyAvg is timevarying, else just uses the single values from RiskyAvg and RiskyStd.
Parameters: None – Returns: Return type: None

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

get_shocks
()¶ Draw idiosyncratic income shocks, just as for IndShockConsumerType, then draw a single common value for the risky asset return. Also draws whether each agent is able to update their risky asset share this period.
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

update_RiskyDstn
()¶ Creates the attributes RiskyDstn from the primitive attributes RiskyAvg, RiskyStd, and RiskyCount, approximating the (perceived) distribution of returns in each period of the cycle.
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)¶ 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.
 mNrmMin –

distance_criteria
= ['vPfuncAdj']¶

HARK.ConsumptionSaving.ConsPortfolioModel.
solveConsPortfolio
(solution_next, ShockDstn, IncShkDstn, RiskyDstn, LivPrb, DiscFac, CRRA, Rfree, PermGroFac, BoroCnstArt, aXtraGrid, ShareGrid, vFuncBool, AdjustPrb, DiscreteShareBool, ShareLimit, IndepDstnBool)¶ Solve the one period problem for a portfoliochoice consumer.
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.
Returns: solution_now – 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).
Return type: