ConsRiskyAssetModel#

This file contains a class that adds a risky asset with a log-normal return factor to IndShockConsumerType. It is meant as a container of methods for dealing with risky assets that will be useful to models what will inherit from it.

HARK.ConsumptionSaving.ConsRiskyAssetModel.make_simple_ShareGrid(ShareCount)#

Make a uniformly spaced grid on the unit interval, representing risky asset shares.

Parameters:

ShareCount (int) – Number of points in the grid.

Returns:

ShareGrid

Return type:

np.array

class HARK.ConsumptionSaving.ConsRiskyAssetModel.IndShockRiskyAssetConsumerType(verbose=False, quiet=False, **kwds)#

Bases: IndShockConsumerType

A consumer type based on IndShockConsumerType, that has access to a risky asset for their savings. The risky asset has lognormal returns that are possibly correlated with his income shocks.

If PortfolioBool is False, then the risky asset share is always one. Otherwise the agent can optimize their risky asset share.

\[\begin{split}\newcommand{\CRRA}{\rho} \newcommand{\DiePrb}{\mathsf{D}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \begin{align*} v_t(m_t) &= \max_{c_t,S_t} u(c_t) + \DiscFac (1-\DiePrb_{t+1}) \mathbb{E}_{t} \left[(\PermGroFac_{t+1}\psi_{t+1})^{1-\CRRA} v_{t+1}(m_{t+1}) \right], \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= \mathsf{R}_{t+1}/(\PermGroFac_{t+1} \psi_{t+1}) a_t + \theta_{t+1}, \\ \mathsf{R}_{t+1} &=S_t\phi_{t+1}\mathbf{R}_{t+1}+ (1-S_t)\mathsf{R}_{t+1}, \\ (\psi_{t+1},\theta_{t+1},\phi_{t+1}) &\sim F_{t+1}, \\ \mathbb{E}[\psi]=\mathbb{E}[\theta] &= 1. \\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \\ \end{align*}\end{split}\]
Constructors:
Solving Parameters:
  • cycles (int) – 0 specifies an infinite horizon model, 1 specifies a finite model.

  • T_cycle (int) – Number of periods in the cycle for this agent type.

  • CRRA (float, \(\rho\)) – Coefficient of Relative Risk Aversion.

  • Rfree (float or list[float], time varying, \(\mathsf{R}\)) – Risk Free interest rate. Pass a list of floats to make Rfree time varying.

  • DiscFac (float, \(\beta\)) – Intertemporal discount factor.

  • LivPrb (list[float], time varying, \(1-\mathsf{D}\)) – Survival probability after each period.

  • PermGroFac (list[float], time varying, \(\Gamma\)) – Permanent income growth factor.

  • BoroCnstArt (float, default=0.0, \(\underline{a}\)) – The minimum Asset/Perminant Income ratio. for this agent, BoroCnstArt must be 0.

  • vFuncBool (bool) – Whether to calculate the value function during solution.

  • CubicBool (bool) – Whether to use cubic spline interpoliation.

  • PortfolioBool (Boolean) – Determines whether agent will use portfolio optimization or they only have access to risky assets. If false, the risky share is always one.

Simulation Parameters:
  • sim_common_Rrisky (Boolean) – Whether risky returns have a shared/common value across agents. If True, Risky return’s can’t be time varying.

  • AgentCount (int) – Number of agents of this kind that are created during simulations.

  • T_age (int) – Age after which to automatically kill agents, None to ignore.

  • T_sim (int, required for simulation) – Number of periods to simulate.

  • track_vars (list[strings]) – List of variables that should be tracked when running the simulation. For this agent, the options are ‘Adjust’, ‘PermShk’, ‘Risky’, ‘TranShk’, ‘aLvl’, ‘aNrm’, ‘bNrm’, ‘cNrm’, ‘mNrm’, ‘pLvl’, and ‘who_dies’.

    Adjust is the array of which agents can adjust

    PermShk is the agent’s permanent income shock

    Risky is the agent’s risky asset shock

    TranShk is the agent’s transitory income shock

    aLvl is the nominal asset level

    aNrm is the normalized assets

    bNrm is the normalized resources without this period’s labor income

    cNrm is the normalized consumption

    mNrm is the normalized market resources

    pLvl is the permanent income level

    who_dies is the array of which agents died

  • aNrmInitMean (float) – Mean of Log initial Normalized Assets.

  • aNrmInitStd (float) – Std of Log initial Normalized Assets.

  • pLvlInitMean (float) – Mean of Log initial permanent income.

  • pLvlInitStd (float) – Std of Log initial permanent income.

  • PermGroFacAgg (float) – Aggregate permanent income growth factor (The portion of PermGroFac attributable to aggregate productivity growth).

  • PerfMITShk (boolean) – Do Perfect Foresight MIT Shock (Forces Newborns to follow solution path of the agent they replaced if True).

  • NewbornTransShk (boolean) – Whether Newborns have transitory shock.

Attributes:
  • solution (list[Consumer solution object]) – Created by the solve() method. Finite horizon models create a list with T_cycle+1 elements, for each period in the solution. Infinite horizon solutions return a list with T_cycle elements for each period in the cycle. If PortfolioBool is True, the solution also contains ShareFunc.

    If PortfolioBool is True, the solution also contains: ShareFunc - The asset share function for this period, defined over normalized market resources \(S=ShareFunc(mNrm)\).

    Visit HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution for more information about the solution.

  • history (Dict[Array]) – Created by running the simulate() method. Contains the variables in track_vars. Each item in the dictionary is an array with the shape (T_sim,AgentCount). Visit HARK.core.AgentType.simulate for more information.

IncShkDstn_default = {'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005}#
RiskyDstn_default = {'RiskyAvg': 1.0803701891, 'RiskyCount': 5, 'RiskyStd': 0.162927447983}#
aXtraGrid_default = {'aXtraCount': 48, 'aXtraExtra': None, 'aXtraMax': 20, 'aXtraMin': 0.001, 'aXtraNestFac': 3}#
ShareGrid_default = {'ShareCount': 25}#
solving_default = {'AdjustPrb': 1.0, 'BoroCnstArt': 0.0, 'CRRA': 2.0, 'CubicBool': False, 'DiscFac': 0.96, 'LivPrb': [0.98], 'PermGroFac': [1.01], 'Rfree': 1.03, 'T_cycle': 1, 'constructors': {'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'RiskyDstn': <function make_lognormal_RiskyDstn>, 'ShareGrid': <function make_simple_ShareGrid>, 'ShareLimit': <function calc_ShareLimit_for_CRRA>, 'ShockDstn': <function combine_IncShkDstn_and_RiskyDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'solution_terminal': <function make_basic_CRRA_solution_terminal>}, 'cycles': 1, 'sim_common_Rrisky': True, 'vFuncBool': False}#
simulation_default = {'AgentCount': 10000, 'NewbornTransShk': False, 'PerfMITShk': False, 'PermGroFacAgg': 1.0, 'T_age': None, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'neutral_measure': False, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.0}#
time_inv_ = ['CRRA', 'DiscFac', 'BoroCnstArt', 'BoroCnstArt', 'vFuncBool', 'CubicBool', 'PortfolioBisect']#
shock_vars_ = ['PermShk', 'TranShk', 'Adjust', 'Risky']#
pre_solve()#

Method that is run automatically just before solution by backward iteration. Solves the (trivial) terminal period and does a quick check on the borrowing constraint and MaxKinks attribute (only relevant in constrained, infinite horizon problems).

update()#

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

Parameters:

None

Return type:

None

update_RiskyDstn()#

Updates the attribute RiskyDstn, approximating the (perceived) distribution of returns in each period of the cycle.

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

update_AdjustDstn()#

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_ShareLimit()#

Creates the attribute ShareLimit, representing the limiting lower bound of risky portfolio share as mNrm goes to infinity, if it is allowed to adjust.

Parameters:

None

Return type:

None

update_ShareGrid()#

Creates the attribute ShareGrid.

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

Draws a new risky return factor.

Parameters:

None

Return type:

None

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

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

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

HARK.ConsumptionSaving.ConsRiskyAssetModel.RiskyAssetConsumerType#

alias of IndShockRiskyAssetConsumerType

class HARK.ConsumptionSaving.ConsRiskyAssetModel.FixedPortfolioShareRiskyAssetConsumerType(verbose=False, quiet=False, **kwds)#

Bases: IndShockRiskyAssetConsumerType

A consumer type that has access to a risky asset for their savings. The risky asset has lognormal returns that are possibly correlated with their income shocks. A fixed portion of their savings are invested in those risky assets.

\[\begin{split}\newcommand{\CRRA}{\rho} \newcommand{\DiePrb}{\mathsf{D}} \newcommand{\PermGroFac}{\Gamma} \newcommand{\Rfree}{\mathsf{R}} \newcommand{\DiscFac}{\beta} \begin{align*} v_t(m_t) &= \max_{c_t} u(c_t) + \DiscFac (1-\DiePrb_{t+1}) \mathbb{E}_{t} \left[(\PermGroFac_{t+1}\psi_{t+1})^{1-\CRRA} v_{t+1}(m_{t+1}) \right], \\ & \text{s.t.} \\ a_t &= m_t - c_t, \\ a_t &\geq \underline{a}, \\ m_{t+1} &= \mathsf{R}_{t+1}/(\PermGroFac_{t+1} \psi_{t+1}) a_t + \theta_{t+1}, \\ \mathsf{R}_{t+1} &=S_t\phi_{t+1}\mathbf{R}_{t+1}+ (1-S_t)\mathsf{R}_{t+1}, \\ (\psi_{t+1},\theta_{t+1},\phi_{t+1}) &\sim F_{t+1}, \\ \mathbb{E}[\psi]=\mathbb{E}[\theta] &= 1. \\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \\ \end{align*}\end{split}\]
Constructors:
Solving Parameters:
  • cycles (int) – 0 specifies an infinite horizon model, 1 specifies a finite model.

  • T_cycle (int) – Number of periods in the cycle for this agent type.

  • CRRA (float, \(\rho\)) – Coefficient of Relative Risk Aversion.

  • Rfree (float or list[float], time varying, \(\mathsf{R}\)) – Risk Free interest rate. Pass a list of floats to make Rfree time varying.

  • RiskyShareFixed (list[float], \(S\)) – Fixed share of assets in the risky asset.

  • DiscFac (float, \(\beta\)) – Intertemporal discount factor.

  • LivPrb (list[float], time varying, \(1-\mathsf{D}\)) – Survival probability after each period.

  • PermGroFac (list[float], time varying, \(\Gamma\)) – Permanent income growth factor.

  • BoroCnstArt (float, default=0.0, \(\underline{a}\)) – The minimum Asset/Perminant Income ratio. for this agent, BoroCnstArt must be 0.

  • vFuncBool (bool) – Whether to calculate the value function during solution.

  • CubicBool (bool) – Whether to use cubic spline interpoliation.

  • PortfolioBool (Boolean) – Determines whether agent will use portfolio optimization or they only have access to risky assets. If false, the risky share is always one.

Simulation Parameters:
  • sim_common_Rrisky (Boolean) – Whether risky returns have a shared/common value across agents. If True, Risky return’s can’t be time varying.

  • AgentCount (int) – Number of agents of this kind that are created during simulations.

  • T_age (int) – Age after which to automatically kill agents, None to ignore.

  • T_sim (int, required for simulation) – Number of periods to simulate.

  • track_vars (list[strings]) – List of variables that should be tracked when running the simulation. For this agent, the options are ‘Adjust’, ‘PermShk’, ‘Risky’, ‘TranShk’, ‘aLvl’, ‘aNrm’, ‘bNrm’, ‘cNrm’, ‘mNrm’, ‘pLvl’, and ‘who_dies’.

    Adjust is the array of which agents can adjust

    PermShk is the agent’s permanent income shock

    Risky is the agent’s risky asset shock

    TranShk is the agent’s transitory income shock

    aLvl is the nominal asset level

    aNrm is the normalized assets

    bNrm is the normalized resources without this period’s labor income

    cNrm is the normalized consumption

    mNrm is the normalized market resources

    pLvl is the permanent income level

    who_dies is the array of which agents died

  • aNrmInitMean (float) – Mean of Log initial Normalized Assets.

  • aNrmInitStd (float) – Std of Log initial Normalized Assets.

  • pLvlInitMean (float) – Mean of Log initial permanent income.

  • pLvlInitStd (float) – Std of Log initial permanent income.

  • PermGroFacAgg (float) – Aggregate permanent income growth factor (The portion of PermGroFac attributable to aggregate productivity growth).

  • PerfMITShk (boolean) – Do Perfect Foresight MIT Shock (Forces Newborns to follow solution path of the agent they replaced if True).

  • NewbornTransShk (boolean) – Whether Newborns have transitory shock.

Attributes:
  • solution (list[Consumer solution object]) – Created by the solve() method. Finite horizon models create a list with T_cycle+1 elements, for each period in the solution. Infinite horizon solutions return a list with T_cycle elements for each period in the cycle.

    Visit HARK.ConsumptionSaving.ConsIndShockModel.ConsumerSolution for more information about the solution.

  • history (Dict[Array]) – Created by running the simulate() method. Contains the variables in track_vars. Each item in the dictionary is an array with the shape (T_sim,AgentCount). Visit HARK.core.AgentType.simulate for more information.

IncShkDstn_default = {'IncUnemp': 0.3, 'IncUnempRet': 0.0, 'PermShkCount': 7, 'PermShkStd': [0.1], 'T_retire': 0, 'TranShkCount': 7, 'TranShkStd': [0.1], 'UnempPrb': 0.05, 'UnempPrbRet': 0.005}#
RiskyDstn_default = {'RiskyAvg': 1.0803701891, 'RiskyCount': 5, 'RiskyStd': 0.162927447983}#
aXtraGrid_default = {'aXtraCount': 48, 'aXtraExtra': None, 'aXtraMax': 20, 'aXtraMin': 0.001, 'aXtraNestFac': 3}#
ShareGrid_default = {'ShareCount': 25}#
solving_default = {'AdjustPrb': 1.0, 'BoroCnstArt': 0.0, 'CRRA': 2.0, 'CubicBool': False, 'DiscFac': 0.96, 'LivPrb': [0.98], 'PermGroFac': [1.01], 'Rfree': 1.03, 'RiskyShareFixed': [0.0], 'T_cycle': 1, 'constructors': {'IncShkDstn': <function construct_lognormal_income_process_unemployment>, 'PermShkDstn': <function get_PermShkDstn_from_IncShkDstn>, 'RiskyDstn': <function make_lognormal_RiskyDstn>, 'ShareGrid': <function make_simple_ShareGrid>, 'ShareLimit': <function calc_ShareLimit_for_CRRA>, 'ShockDstn': <function combine_IncShkDstn_and_RiskyDstn>, 'TranShkDstn': <function get_TranShkDstn_from_IncShkDstn>, 'aXtraGrid': <function make_assets_grid>, 'solution_terminal': <function make_basic_CRRA_solution_terminal>}, 'cycles': 1, 'sim_common_Rrisky': True, 'vFuncBool': False}#
simulation_default = {'AgentCount': 10000, 'NewbornTransShk': False, 'PerfMITShk': False, 'PermGroFacAgg': 1.0, 'T_age': None, 'aNrmInitMean': 0.0, 'aNrmInitStd': 1.0, 'neutral_measure': False, 'pLvlInitMean': 0.0, 'pLvlInitStd': 0.0}#
time_vary_ = ['LivPrb', 'PermGroFac', 'RiskyShareFixed']#