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.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: \(c_t=\text{cFuncAdj} (m_t)\).
ShareFuncAdj (Interp1D) – Risky share function over normalized market resources when the agent is able to adjust their portfolio shares: \(S_t=\text{ShareFuncAdj} (m_t)\).
vFuncAdj (ValueFuncCRRA) – Value function over normalized market resources when the agent is able to adjust their portfolio shares: \(v_t=\text{vFuncAdj} (m_t)\).
vPfuncAdj (MargValueFuncCRRA) – Marginal value function over normalized market resources when the agent is able to adjust their portfolio shares: \(v'_t=\text{vPFuncAdj} (m_t)\).
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: \(c_t=\text{cFuncFxd} (m_t,S_t)\).
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: \(v_t=\text{vFuncFxd}(m_t,S_t)\).
dvdmFuncFxd (MargValueFuncCRRA) – The derivative of the value function with respect to normalized market resources when the agent is Not able to adjust their portfolio shares, so they are fixed: \(\frac{dv_t}{dm_t}=\text{vFuncFxd}(m_t,S_t)\).
dvdsFuncFxd (MargValueFuncCRRA) – The derivative of the value function with respect to risky asset share when the agent is Not able to adjust their portfolio shares,so they are fixed: \(\frac{dv_t}{dS_t}=\text{vFuncFxd}(m_t,S_t)\).
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: \(S^{*}_t=\text{vFuncFxd}(m_t)\).
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']#
- class HARK.ConsumptionSaving.ConsPortfolioModel.PortfolioConsumerType(verbose=False, quiet=False, **kwds)#
Bases:
IndShockRiskyAssetConsumerType
A consumer type based on IndShockRiskyAssetConsumerType, with portfolio optimization. The agent is only able to change their risky asset share with a certain probability.
\[\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,S_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},S_{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}, \\ S_{t+1} &= \begin{cases} S^{*}_t & \text{if } p_t < \wp\\ S_t & \text{if } p_t \geq \wp, \end{cases}\\ (\psi_{t+1},\theta_{t+1},\phi_{t+1},p_t) &\sim F_{t+1}, \\ \mathbb{E}[\psi]=\mathbb{E}[\theta] &= 1.\\ u(c) &= \frac{c^{1-\CRRA}}{1-\CRRA} \\ \end{align*}\end{split}\]- Constructors:
IncShkDstn (Constructor, \(\psi\), \(\theta\)) – The agent’s income shock distributions.
It’s default constructor is
HARK.Calibration.Income.IncomeProcesses.construct_lognormal_income_process_unemployment()
aXtraGrid (Constructor) – The agent’s asset grid.
It’s default constructor is
HARK.utilities.make_assets_grid()
ShareGrid (Constructor) – The agent’s risky asset share grid
It’s default constructor is
HARK.ConsumptionSaving.ConsRiskyAssetModel.make_simple_ShareGrid()
RiskyDstn (Constructor, \(\phi\)) – The agent’s asset shock distribution for risky assets.
It’s default constructor is
HARK.Calibration.Assets.AssetProcesses.make_lognormal_RiskyDstn()
- 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.
AdjustPrb (float or list[float], time varying) – Must be between 0 and 1. Probability that the agent can update their risky portfolio share each period. Pass a list of floats to make AdjustPrb time varying.
- 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.ConsPortfolioModel.PortfolioSolution
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). VisitHARK.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}#
- aXtraGrid_default = {'aXtraCount': 200, 'aXtraExtra': None, 'aXtraMax': 100, 'aXtraMin': 0.001, 'aXtraNestFac': 1}#
- RiskyDstn_default = {'RiskyAvg': 1.08, 'RiskyCount': 5, 'RiskyStd': 0.18362634887}#
- solving_default = {'AdjustPrb': 1.0, 'BoroCnstArt': 0.0, 'CRRA': 5.0, 'CubicBool': False, 'DiscFac': 0.9, 'DiscreteShareBool': False, '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_portfolio_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', 'AdjustPrb', 'DiscreteShareBool']#
- 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
- 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