ConsRiskyAssetModel¶
This file contains a class that adds a risky asset with a log-normal return factor to IndShockConsumerType. This class is not a fully specified model and therefore has no solution or simulation methods. It is meant as a container of methods for dealing with risky assets that will be useful to models what will inherit from it.
- class HARK.ConsumptionSaving.ConsRiskyAssetModel.ConsFixedPortfolioIndShkRiskyAssetSolver(solution_next: HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution, IncShkDstn: HARK.distribution.DiscreteDistribution, TranShkDstn: HARK.distribution.DiscreteDistribution, PermShkDstn: HARK.distribution.DiscreteDistribution, RiskyDstn: HARK.distribution.DiscreteDistribution, ShockDstn: HARK.distribution.DiscreteDistribution, LivPrb: float, DiscFac: float, CRRA: float, Rfree: float, RiskyShareFixed: float, PermGroFac: float, BoroCnstArt: float, aXtraGrid: <built-in function array>, vFuncBool: bool, CubicBool: bool, IndepDstnBool: bool)¶
Bases:
ConsIndShockSolver
- IncShkDstn: DiscreteDistribution¶
- PermShkDstn: DiscreteDistribution¶
- RiskyDstn: DiscreteDistribution¶
- ShockDstn: DiscreteDistribution¶
- TranShkDstn: DiscreteDistribution¶
- aXtraGrid: array¶
- calc_EndOfPrdvP()¶
Calculate end-of-period marginal value of assets at each point in aNrmNow. Does so by taking a weighted sum of next period marginal values across income shocks (in a preconstructed grid self.mNrmNext).
- Parameters:
none –
- Returns:
EndOfPrdvP – A 1D array of end-of-period marginal value of assets
- Return type:
np.array
- 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 assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
- Return type:
none
- make_EndOfPrdvFunc(EndOfPrdvP)¶
Construct the end-of-period value function for this period, storing it as an attribute of self for use by other methods.
- Parameters:
EndOfPrdvP (np.array) – Array of end-of-period marginal value of assets corresponding to the asset values in self.aNrmNow.
- Return type:
none
- r_port(shock)¶
- 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, 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.DiscreteDistribution) – A DiscreteDistribution with a pmv and two point value arrays in X, order: 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.
- Return type:
None
- solution_next: ConsumerSolution¶
- class HARK.ConsumptionSaving.ConsRiskyAssetModel.ConsIndShkRiskyAssetSolver(solution_next: ConsumerSolution, IncShkDstn: DiscreteDistribution, TranShkDstn: DiscreteDistribution, PermShkDstn: DiscreteDistribution, RiskyDstn: DiscreteDistribution, ShockDstn: DiscreteDistribution, LivPrb: float, DiscFac: float, CRRA: float, Rfree: float, PermGroFac: float, BoroCnstArt: float, aXtraGrid: array, vFuncBool: bool, CubicBool: bool, IndepDstnBool: bool)¶
Bases:
ConsIndShockSolver
Solver for an agent that can save in an asset that has a risky return.
- IncShkDstn: DiscreteDistribution¶
- PermShkDstn: DiscreteDistribution¶
- RiskyDstn: DiscreteDistribution¶
- ShockDstn: DiscreteDistribution¶
- TranShkDstn: DiscreteDistribution¶
- aXtraGrid: array¶
- calc_EndOfPrdvP()¶
Calculate end-of-period marginal value of assets at each point in aNrmNow. Does so by taking a weighted sum of next period marginal values across income shocks (in a preconstructed grid self.mNrmNext).
- Parameters:
none –
- Returns:
EndOfPrdvP – A 1D array of end-of-period marginal value of assets
- Return type:
np.array
- calc_ExpMargValueFunc(dstn, func, grid)¶
Calculate Expected Marginal Value Function given a distribution, a function, and a set of interpolation nodes.
- calc_ExpValueFunc(dstn, func, grid)¶
Calculate Expected Value Function given distribution, function, and interpolating nodes.
- calc_preIncShkvFunc(vFuncNext)¶
Calculate Expected Value Function prior to realization of income uncertainty.
- calc_preIncShkvPfunc(vPfuncNext)¶
Calculate Expected Marginal Value Function before the realization of income shocks.
- calc_preRiskyShkvFunc(preIncShkvFunc)¶
Calculate Expected Value Function prior to realization of risky return.
- calc_preRiskyShkvPfunc(preIncShkvPfunc)¶
Calculate Expected Marginal Value Function before the realization of the risky return.
- 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 assets to end the period with. If it is less than the natural borrowing constraint, then it is irrelevant; BoroCnstArt=None indicates no artificial bor- rowing constraint.
- Return type:
none
- make_EndOfPrdvFunc(EndOfPrdvP)¶
Construct the end-of-period value function for this period, storing it as an attribute of self for use by other methods.
- Parameters:
EndOfPrdvP (np.array) – Array of end-of-period marginal value of assets corresponding to the asset values in self.aNrmNow.
- Return type:
none
- prepare_to_calc_EndOfPrdvP()¶
Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period.
- Parameters:
none –
- Returns:
aNrmNow – A 1D array of end-of-period assets; also stored as attribute of self.
- Return type:
np.array
- 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, 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.DiscreteDistribution) – A DiscreteDistribution with a pmv and two point value arrays in X, order: 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.
- Return type:
None
- solution_next: ConsumerSolution¶
- class HARK.ConsumptionSaving.ConsRiskyAssetModel.ConsPortfolioIndShkRiskyAssetSolver(solution_next: HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution, IncShkDstn: HARK.distribution.DiscreteDistribution, TranShkDstn: HARK.distribution.DiscreteDistribution, PermShkDstn: HARK.distribution.DiscreteDistribution, RiskyDstn: HARK.distribution.DiscreteDistribution, ShockDstn: HARK.distribution.DiscreteDistribution, LivPrb: float, DiscFac: float, CRRA: float, Rfree: float, PermGroFac: float, BoroCnstArt: float, aXtraGrid: <built-in function array>, vFuncBool: bool, CubicBool: bool, IndepDstnBool: bool, ShareGrid: <built-in function array>, ShareLimit: float, PortfolioBisect: bool)¶
Bases:
ConsIndShkRiskyAssetSolver
Construct the risky share function twice, once with respect to End of Period which depends on Liquid assets, and another with respect to Beginning of Period which depends on Cash on Hand.
- calc_EndOfPrdvP()¶
Calculate end-of-period marginal value of assets at each point in aNrmNow. Does so by taking a weighted sum of next period marginal values across income shocks (in a preconstructed grid self.mNrmNext).
- Parameters:
none –
- Returns:
EndOfPrdvP – A 1D array of end-of-period marginal value of assets
- Return type:
np.array
- calc_preRiskyShkvPfunc(preIncShkvPfunc)¶
Calculate Expected Marginal Value Function before the realization of the risky return.
Optimize the risky share of portfolio given End of Period Marginal Value wrt a given risky share. Returns optimal share and End of Period Marginal Value of Liquid Assets at the optimal share.
- prepare_to_calc_EndOfPrdvP()¶
Prepare to calculate end-of-period marginal value by creating an array of market resources that the agent could have next period, considering the grid of end-of-period assets and the distribution of shocks he might experience next period.
- Parameters:
none –
- Returns:
aNrmNow – A 1D array of end-of-period assets; also stored as attribute of self.
- Return type:
np.array
- 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, 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.DiscreteDistribution) – A DiscreteDistribution with a pmv and two point value arrays in X, order: 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.
- Return type:
None
- solve()¶
Solves the single period consumption-saving problem using the method of endogenous gridpoints. Solution includes a consumption function cFunc (using cubic or linear splines), a marginal value function vPfunc, a min- imum acceptable level of normalized market resources mNrmMin, normalized human wealth hNrm, and bounding MPCs MPCmin and MPCmax. It might also have a value function vFunc and marginal marginal value function vPPfunc.
- Parameters:
none –
- Returns:
solution – The solution to the single period consumption-saving problem.
- Return type:
- class HARK.ConsumptionSaving.ConsRiskyAssetModel.IndShockRiskyAssetConsumerType(verbose=False, quiet=False, **kwds)¶
Bases:
IndShockConsumerType
A consumer type that has access to a risky asset for his savings. The risky asset has lognormal returns that are possibly correlated with his income shocks.
There is a friction that prevents the agent from adjusting his portfolio at any given period with an exogenously given probability. The meaning of “adjusting his portfolio” depends on the particular model.
- get_Adjust()¶
Sets the attribute Adjust 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 –
- 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 attribute Risky as a single draw from a lognormal distribution. Uses the attributes RiskyAvgTrue and RiskyStdTrue if RiskyAvg is time-varying, else just uses the single values from RiskyAvg and RiskyStd.
- Parameters:
None –
- 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 adjust their portfolio this period.
- Parameters:
None –
- Return type:
None
- initialize_sim()¶
Initialize the state of simulation attributes. Simply calls the same method for IndShockConsumerType, then initializes the new states/shocks Adjust and Share.
- Parameters:
None –
- 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 –
- Return type:
none
- shock_vars_ = ['PermShk', 'TranShk', 'Adjust', 'Risky']¶
- time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'PortfolioBisect']¶
- update()¶
Update the income process, the assets grid, and the terminal solution.
- Parameters:
None –
- Return type:
None
- update_AdjustPrb()¶
Checks and updates the exogenous probability of the agent being allowed to rebalance his portfolio/contribution scheme. It can be time varying.
- Parameters:
None. –
- 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 –
- Return type:
None
Creates the attribute ShareGrid as an evenly spaced grid on [0.,1.], using the primitive parameter ShareCount.
- Parameters:
None –
- Return type:
None
Creates the attribute ShareLimit, representing the limiting lower bound of risky portfolio share as mNrm goes to infinity.
- Parameters:
None –
- Return type:
None
- update_ShockDstn()¶
Combine the income shock distribution (over PermShk and TranShk) with the risky return distribution (RiskyDstn) to make a new attribute called ShockDstn.
- Parameters:
None –
- Return type:
None
- HARK.ConsumptionSaving.ConsRiskyAssetModel.RiskyAssetConsumerType¶
alias of
IndShockRiskyAssetConsumerType