-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
New model: Labor supply on intensive margin #509
Conversation
This commit is mostly a copy-paste of files that had been sitting in my student submission folder for literally two years. Most of the programming here was done by Tiphanie Magne as a course project in spring/summer 2017, with some assistance from me. (TODO: Make sure she gets tagged/credited on the PR for this branch.) I dropped in the files as they were on my computer, changed the HARK package names (the work predated that), and it ran successfully. Still to do: Clean up some comments and documentation, add life cycle example, make sure simulation exists (and works), move example parameter dictionary into ConsumerParameters.py (from blahblahTM.py).
Added/edited various solver comments and changed a few variable names. Also changed aXtraMax in parameters, which reveals that the "negative labor" problem is handled correctly in the solver... but it can still *extrapolate* to negative labor.
Did this work several days ago, forgot to commit. Rest of comments and docstrings in file still need to be gone over.
Finished moving example parameters from ConsumerParametersTM.py into ConsumerParameters.py, and deleting ConsumerParametersTM.py. Finished adding lifecycle example into main block (Just took the lifecycle example from ConsIndShockModel, as what I have interpreted). Some attempts on fixing the simulation for the labor model, it works as it does simulate some results, but I do not know how to test whether it is correct or not.
…nderstand the getControls() method and the consumption function in the Labor model, but the plot seems to make sense, please review on this. I am pretty certain that the ConsumerParameters.py file is fine.
…r intensive margin consumer. But for some unknown reason, it does not allow me to set T_retire above 0. If T_retire is set, then there is an IndexError at line 774 in interpolation.py. After tracking of the error, I suspect that something is messed up in the process of passing bNrmGrid_rep into Interpolation.LinearInterp._eval0rder. If I set T_retire = 0, the print of length of bNrmGrid_rep and x_list in _eval0rder is 200, 201, 200, 16. If I set T_retire > 0, the print of length of bNrmGrid_rep and x_list in _eval0rder is 200, 201, 200, 1. However, I cannot identify why T_retire > 0 gives such a result. Will continue working on this.
…r a labor intensive margin consumer." This reverts commit 5820958.
One problem: according to the model name 'endogenous labor', I assume that we should not set a specific retire period for the consumer, everything should be decide by the agent. Furthermore, if I do set a retirement period T_retire for the agent, then lifecycle example gives an IndexError. After some investigation, I found that the problem reside in line 2328-2337 in ConsIndShockModel, where we handle the IncomeDstnRet if T_retire > 0. I do not want to touch on that without instruction as it may have big influence.
Lifecycle figures for intensive margin labor model now plot across periods, using the median shock (more or less) rather than across shocks. These plots now have "nice" xlim and ylim, but infinite horizon figs do not. We can fix that later.
Adds consumption-saving model with labor supply choice (intensive margin). Main code written by Tiphanie Magne in summer 2017; cleaned up and prepared for master HARK by Shiqi Li and me.
What if, for new Models, rather than putting all the test and demo code into the
This has two benefits:
|
Yes, that's a better structure. I'll move the code. |
Adopted new style of default parameters.
Following new style in Mridul's refactoring PR, moved all of the main block code for ConsLaborModel into a new example file in the appropriate directory. Also did a bunch of cleanup on simulation methods for the labor model, which were incorrect.
Ok, the main block code has been moved to a new examples file, and tested in place. This revealed a bunch of problems with the code (now fixed), so it was a very good idea. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See one docstring error.
I see that the example code has moved. I don't see any automated tests.
While that seems standard for HARK, in general when doing code reviews I point out that automated tests are best done when a feature is first committed.
|
||
def getControls(self): | ||
''' | ||
Calculates consumption for each consumer of this type using the consumption functions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this docstring is incorrect. There are more controls than just consumption in this model
for the unit tests in #455 I use ideas from the example and then create incremental unit test. Example: testing one function |
Added updateLbrCost Function
updateLbrCost method didn't work as intended, as LbrCost was an array, not a list; added call to tolist(). Fixed documentation error in a simulation method that someone else flagged. Also added two line getStates method, which isn't strictly necessary. Inherited method calculates mNrm "prematurely", which is then overwritten by a later sim method in this model. New getStates method simply "erases" that premature calculation.
I fixed that docstring error just now (thanks). I've never made automated tests before; I'll try to get around to figuring out how to do that and put them in here. |
@mnwhite I'd be happy to do a quick call with you some time about automated tests! |
Changed some division symbols to correctly use integer division, and adjusted lifecycle example dictionary.
Shall I merge this in? It's better if there are tests, but there is no such general policy requiring tests on PRs at this point, as far as I know. |
Thank you! We will make tests, I swear.
…On Wed, Feb 26, 2020 at 4:22 PM Sebastian Benthall ***@***.***> wrote:
Merged #509 <#509> into master.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#509?email_source=notifications&email_token=ADKRAFMWJG45E3YXFXACL7LRE3MRNA5CNFSM4KSPQYJKYY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOW5IBY7Y#event-3075480703>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKRAFMMAQSGMBW5XFAJ7TTRE3MRNANCNFSM4KSPQYJA>
.
|
This PR provides a new model for HARK, in which agents make both a consumption-saving decisions and a (continuous) labor-leisure decision. Agents observe their permanent and transitory productivity shocks before deciding how much labor to supply each period, so TranShk is a second state variable. Utility function has a Cobb-Douglas-like aggregator for leisure and consumption under a single CRRA term.
Most model code was written by Tiphanie Magne in 2017, with some cleanup by me in 2019 and then a bit more by Jack Shiqi Li.
I could swear this was merged into master months ago, but apparently not.