Skip to content

Quasi hyperbolic pf - #833

Open
MridulS wants to merge 8 commits into
econ-ark:mainfrom
MridulS:quasi-hyperbolic-pf
Open

Quasi hyperbolic pf#833
MridulS wants to merge 8 commits into
econ-ark:mainfrom
MridulS:quasi-hyperbolic-pf

Conversation

@MridulS

@MridulS MridulS commented Sep 3, 2020

Copy link
Copy Markdown
Member

implements #215

replaces #815

g-carranza and others added 7 commits December 20, 2018 17:54
@econ-ark econ-ark deleted a comment from github-actions Bot Sep 26, 2020
@github-actions

Copy link
Copy Markdown
Contributor

Binder 👈 Launch a binder notebook on this branch

@MridulS MridulS removed their assignment Oct 1, 2020
@llorracc

llorracc commented Oct 1, 2020

Copy link
Copy Markdown
Collaborator

/binder

@github-actions

github-actions Bot commented Oct 1, 2020

Copy link
Copy Markdown
Contributor

Binder 👈 Launch a binder notebook on this branch

@sbenthall

Copy link
Copy Markdown
Contributor

@Mv77 to look at this as CDC's RA

@sbenthall sbenthall added this to the 1.x.y milestone Dec 10, 2020
@Mv77

Mv77 commented Jun 15, 2021

Copy link
Copy Markdown
Collaborator

I did not get to this in my time as Chris's RA this winter and I don't anticipate working on it for now.

@sbenthall

Copy link
Copy Markdown
Contributor

@llorracc @MridulS I'm wondering if there is somebody else who could review this.

@sbenthall
sbenthall requested a review from mnwhite April 6, 2022 16:12
@sbenthall

Copy link
Copy Markdown
Contributor

@MridulS to fix conflict, then @mnwhite to review?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR implements quasi-hyperbolic discounting for perfect foresight consumer agents in HARK, addressing issue #215 and replacing PR #815. The implementation uses a "beta-delta" approach where naive agents have present-biased preferences.

Changes:

  • Modified solveOneCycle in core.py to support geometric solutions for backward induction
  • Added HyperbolicBeta parameter to PerfForesightConsumerType and its solver
  • Updated discount factor calculation to incorporate hyperbolic discounting
  • Added example configurations and a demonstration notebook

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 9 comments.

File Description
HARK/core.py Modified solveOneCycle to conditionally use geometric_solution attribute for backward induction instead of current solution
HARK/ConsumptionSaving/ConsIndShockModel.py Added HyperbolicBeta parameter to solver and agent type; updated effective discount factor calculation; reformatted init dictionary
examples/Journeys/Quickstart_tutorial/Jounery_1_param.py Added Hyperbolic_beta parameter to example configuration
HARK/ConsumptionSaving/ConsIndShockModelDemos/testing_hyperbolic_discounting.ipynb New Jupyter notebook demonstrating and validating the hyperbolic discounting implementation with algebraic verification

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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
Hyperbolic_beta = 1 # Naive hyperbolic discount factor

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 parameter name "Hyperbolic_beta" in the example file is inconsistent with "HyperbolicBeta" used in the main implementation. Parameter names should be consistent across the codebase. Consider using "HyperbolicBeta" (without underscore) to match the implementation.

Copilot uses AI. Check for mistakes.
Comment on lines +399 to 401

Returns:
----------

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.
"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.
"cell_type": "markdown",
"metadata": {},
"source": [
"I implement hyperbolic discounting by modyfing the `solveOneCycle` function in `core.py`. If a `geometric_solution` attribute is specified, the `solveOneCycle` function uses the solutions specified in this attribute list in its backward induction loop, instead of the current solution. The exponential discount factor is also resized by a factor of the `hyperbolic` discount variable. "

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 notebook documentation contains a typo: "modyfing" should be "modifying".

Suggested change
"I implement hyperbolic discounting by modyfing the `solveOneCycle` function in `core.py`. If a `geometric_solution` attribute is specified, the `solveOneCycle` function uses the solutions specified in this attribute list in its backward induction loop, instead of the current solution. The exponential discount factor is also resized by a factor of the `hyperbolic` discount variable. "
"I implement hyperbolic discounting by modifying the `solveOneCycle` function in `core.py`. If a `geometric_solution` attribute is specified, the `solveOneCycle` function uses the solutions specified in this attribute list in its backward induction loop, instead of the current solution. The exponential discount factor is also resized by a factor of the `hyperbolic` discount variable. "

Copilot uses AI. Check for mistakes.
Comment thread HARK/core.py
solution_t = solveOnePeriod(**temp_dict)
solution_cycle.insert(0, solution_t)
solution_next = solution_t
# solution_next = s/olution_t

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.

There is a commented-out line with a typo ("s/olution_t" instead of "solution_t"). This commented code should be removed entirely as it serves no purpose.

Suggested change
# solution_next = s/olution_t

Copilot uses AI. Check for mistakes.
'T_age' : T_age,
'T_cycle' : T_cycle
'T_cycle' : T_cycle,
'Hyperbolic_beta' : Hyperbolic_beta

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 parameter name "Hyperbolic_beta" (with underscore) is inconsistent with "HyperbolicBeta" (without underscore) used elsewhere in the code. This should be "HyperbolicBeta" to match the implementation in ConsIndShockModel.py.

Copilot uses AI. Check for mistakes.
"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.
"""
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.
"geom_solution = deepcopy(PFexample.solution)\n",
"PFexample_hyperbolic = deepcopy(PFexample)\n",
"PFexample_hyperbolic.geometric_solution = geom_solution\n",
"PFexample_hyperbolic.Hyperbolic_beta=0.7\n",

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 notebook uses "Hyperbolic_beta" (line 223) which is inconsistent with the parameter name "HyperbolicBeta" used in the implementation. This should be "HyperbolicBeta" (without underscore) to match the code.

Suggested change
"PFexample_hyperbolic.Hyperbolic_beta=0.7\n",
"PFexample_hyperbolic.HyperbolicBeta=0.7\n",

Copilot uses AI. Check for mistakes.
@MridulS

MridulS commented Mar 8, 2026

Copy link
Copy Markdown
Member Author

The issue was turned into a discussion. Should I still try to clean this up and sync up with new changes? @mnwhite

@mnwhite

mnwhite commented Mar 8, 2026 via email

Copy link
Copy Markdown
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Stale

Development

Successfully merging this pull request may close these issues.

8 participants