Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 31 additions & 17 deletions HARK/ConsumptionSaving/ConsIndShockModel.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ def __init__(
PermGroFac,
BoroCnstArt,
MaxKinks,
HyperbolicBeta,
):
"""
Constructor for a new ConsPerfForesightSolver.
Expand Down Expand Up @@ -393,6 +394,9 @@ def __init__(
additional points will be thrown out. Only relevant in infinite
horizon model with artificial borrowing constraint.

HyperbolicBeta: float
Quasi hyperbolic impatience factor in "beta-delta" preferences.

Returns:
----------
Comment on lines +399 to 401

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The docstring is missing a blank line before the "Returns:" section and has inconsistent formatting with an empty line after the description. The formatting should match the project's documentation standards.

Suggested change
Returns:
----------
Returns
-------

Copilot uses AI. Check for mistakes.
None
Expand All @@ -414,6 +418,7 @@ def __init__(
PermGroFac=PermGroFac,
BoroCnstArt=BoroCnstArt,
MaxKinks=MaxKinks,
HyperbolicBeta=HyperbolicBeta,
)

def defUtilityFuncs(self):
Expand Down Expand Up @@ -612,7 +617,7 @@ def solve(self):
The solution to this period's problem.
"""
self.defUtilityFuncs()
self.DiscFacEff = self.DiscFac * self.LivPrb
self.DiscFacEff = self.DiscFac * self.LivPrb * self.HyperbolicBeta

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new HyperbolicBeta functionality lacks automated test coverage. While there is a Jupyter notebook demonstrating the feature, there are no unit tests in the test_PerfForesightConsumerType.py file that verify the quasi-hyperbolic discounting behavior. Consider adding tests that verify the consumption functions match the expected algebraic solutions when HyperbolicBeta is not equal to 1.

Copilot uses AI. Check for mistakes.
self.makePFcFunc()
self.defValueFuncs()
solution = ConsumerSolution(
Expand Down Expand Up @@ -1528,21 +1533,22 @@ def prepareToCalcEndOfPrdvP(self):

# Make a dictionary to specify a perfect foresight consumer type
init_perfect_foresight = {
'CRRA': 2.0, # Coefficient of relative risk aversion,
'Rfree': 1.03, # Interest factor on assets
'DiscFac': 0.96, # Intertemporal discount factor
'LivPrb': [0.98], # Survival probability
'PermGroFac': [1.01], # Permanent income growth factor
'BoroCnstArt': None, # Artificial borrowing constraint
'MaxKinks': 400, # Maximum number of grid points to allow in cFunc (should be large)
'AgentCount': 10000, # Number of agents of this type (only matters for simulation)
'aNrmInitMean' : 0.0, # Mean of log initial assets (only matters for simulation)
'aNrmInitStd' : 1.0, # Standard deviation of log initial assets (only for simulation)
'pLvlInitMean' : 0.0, # Mean of log initial permanent income (only matters for simulation)
'pLvlInitStd' : 0.0, # Standard deviation of log initial permanent income (only matters for simulation)
'PermGroFacAgg' : 1.0,# Aggregate permanent income growth factor: portion of PermGroFac attributable to aggregate productivity growth (only matters for simulation)
'T_age' : None, # Age after which simulated agents are automatically killed
'T_cycle' : 1 # Number of periods in the cycle for this agent type
"CRRA": 2.0, # Coefficient of relative risk aversion,
"Rfree": 1.03, # Interest factor on assets
"DiscFac": 0.96, # Intertemporal discount factor
"LivPrb": [0.98], # Survival probability
"PermGroFac": [1.01], # Permanent income growth factor
"BoroCnstArt": None, # Artificial borrowing constraint
"MaxKinks": 400, # Maximum number of grid points to allow in cFunc (should be large)
"AgentCount": 10000, # Number of agents of this type (only matters for simulation)
"aNrmInitMean": 0.0, # Mean of log initial assets (only matters for simulation)
"aNrmInitStd": 1.0, # Standard deviation of log initial assets (only for simulation)
"pLvlInitMean": 0.0, # Mean of log initial permanent income (only matters for simulation)
"pLvlInitStd": 0.0, # Standard deviation of log initial permanent income (only matters for simulation)
"PermGroFacAgg": 1.0, # Aggregate permanent income growth factor (only matters for simulation)
"T_age": None, # Age after which simulated agents are automatically killed
"T_cycle": 1, # Number of periods in the cycle for this agent type
"HyperbolicBeta": 1,

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HyperbolicBeta parameter is added to init_perfect_foresight but lacks a descriptive comment like all other parameters in the dictionary. Add a comment such as "# Quasi-hyperbolic discount factor (naive agents)" to maintain consistency.

Suggested change
"HyperbolicBeta": 1,
"HyperbolicBeta": 1, # Quasi-hyperbolic discount factor (naive agents)

Copilot uses AI. Check for mistakes.
}


Expand All @@ -1566,7 +1572,15 @@ class PerfForesightConsumerType(AgentType):
MPCmax=1.0,
)
time_vary_ = ["LivPrb", "PermGroFac"]
time_inv_ = ["CRRA", "Rfree", "DiscFac", "MaxKinks", "BoroCnstArt"]
time_inv_ = [
"CRRA",
"Rfree",
"DiscFac",
"MaxKinks",
"BoroCnstArt",
"HyperbolicBeta",
"geometric_solution",

Copilot AI Jan 28, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding "geometric_solution" to time_inv_ makes it a required parameter that must be provided during initialization. This could break existing code that creates PerfForesightConsumerType instances without this parameter. Consider making this parameter optional by checking for its existence with hasattr() (as already done in core.py line 923) rather than requiring it as a time-invariant parameter.

Suggested change
"geometric_solution",

Copilot uses AI. Check for mistakes.
]
poststate_vars_ = ["aNrmNow", "pLvlNow"]
shock_vars_ = []

Expand Down
Loading
Loading