Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reshuffling method [WIP] #1244

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open

Add reshuffling method [WIP] #1244

wants to merge 18 commits into from

Conversation

wdu9
Copy link
Collaborator

@wdu9 wdu9 commented Mar 19, 2023

Please ensure your pull request adheres to the following guidelines:

  • Tests for new functionality/models or Tests to reproduce the bug-fix in code.
  • Updated documentation of features that add new functionality.
  • Update CHANGELOG.md with major/minor changes.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2023

Codecov Report

Patch coverage: 34.92% and project coverage change: -0.26 ⚠️

Comparison is base (80d027d) 73.31% compared to head (842efa7) 73.05%.

❗ Current head 842efa7 differs from pull request most recent head 53c699e. Consider uploading reports for the commit 53c699e to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1244      +/-   ##
==========================================
- Coverage   73.31%   73.05%   -0.26%     
==========================================
  Files          76       75       -1     
  Lines       12548    12576      +28     
==========================================
- Hits         9199     9188      -11     
- Misses       3349     3388      +39     
Impacted Files Coverage Δ
HARK/ConsumptionSaving/ConsIndShockModel.py 83.90% <34.92%> (-3.14%) ⬇️

... and 16 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@llorracc
Copy link
Collaborator

llorracc commented Mar 20, 2023 via email

@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Patch coverage: 85.88% and project coverage change: +0.07% 🎉

Comparison is base (4f644bf) 72.64% compared to head (5e35de5) 72.71%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1244      +/-   ##
==========================================
+ Coverage   72.64%   72.71%   +0.07%     
==========================================
  Files          78       78              
  Lines       13028    13106      +78     
==========================================
+ Hits         9464     9530      +66     
- Misses       3564     3576      +12     
Files Changed Coverage Δ
HARK/ConsumptionSaving/ConsIndShockModel.py 86.34% <65.71%> (-0.70%) ⬇️
...nsumptionSaving/tests/test_IndShockConsumerType.py 80.89% <100.00%> (+1.87%) ⬆️
HARK/distribution.py 84.76% <100.00%> (+0.30%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB


if self.perf_reshuffle == True:# when true, permanent and transitory shocks are evenly distributed across both newborns and non newborns.
Min_AgentCount = check_and_convert_to_int(lcm/(1-self.LivPrb[0])) # total number of agents
if (self.AgentCount/Min_AgentCount).is_integer() == False: # check if Agentcount is appropriate to implement perfect reshuffling
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need to test if a boolean == False in an if statement.

Copy link
Contributor

Choose a reason for hiding this comment

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

What I mean is... it's better style to use a 'not' here (i.e. if not (...).is_integer():
https://www.w3schools.com/python/ref_keyword_not.asp

... or to do if (expression that evaluates to true) ... else: (do the thing on the condition that it's false)

This is just a style nitpick.

@sbenthall
Copy link
Contributor

Hi @wdu9

I'm looking over this PR and trying to understand the parts of it. I'm seeing three things:

  • passing self.reshuffle to the exact_match argument when shocks are drawn from a distribution
  • A test to make sure that the the AgentCount is an exact multiple of the MinAgentCount (which I guess is the number of equiprobably discretized parts of the distribution)
  • A third thing that I'm not sure I understand, having to with unemployment draws?

https://github.com/econ-ark/HARK/pull/1244/files#diff-7f09d28a3d4136ae35d8835cd1352f060da6e0114fe617c34374c8b57d41a57eR2273-R2301

Am I reading this right? Can you tell me if anything else is happening that I'm missing?

Any explanation of this could go into the docstrings to improve the API documentation, which is part of the checklist for merging PRs.

@llorracc
Copy link
Collaborator

llorracc commented Aug 10, 2023 via email

@wdu9
Copy link
Collaborator Author

wdu9 commented Aug 11, 2023

Hi @sbenthall ,

Yes you are exactly correct. Much of the code is written to check whether the number of agents is the correct multiple needed to implement the reshuffling method. If the number of agents is appropriate then reshuffle calls exact_match which does most of the heavy lifting by allowing draws to be drawn "perfectly".

The other method that was altered was sim_death to ensure that the number of agents that die each period is exactly (1-LivPrb).

I plan to make the code clearer as the current code is crude in how it determines if AgentCount is the correct multiple. It does work however.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants