-
-
Notifications
You must be signed in to change notification settings - Fork 303
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
Model tools: Add various utility functions #179
Conversation
Codecov Report
@@ Coverage Diff @@
## master #179 +/- ##
==========================================
- Coverage 90.5% 90.39% -0.11%
==========================================
Files 23 24 +1
Lines 1590 1624 +34
==========================================
+ Hits 1439 1468 +29
- Misses 151 156 +5
Continue to review full report at Codecov.
|
This is a cool idea that could be used to replace some of the code in the optimal taxation lectures! I guess you prefer |
Hey @cc7768 let me know when you want a re view on this one. I've seen a few changes come in since the PR opened os I've been waiting for your word to look closer |
I think this version is ready to review. There are 4 utility functions and their first derivative. There are also tests for each of them. I will likely add some additional features (production function, aggregation functions, wage processes, etc...) in future PRs, but it is easier for me to do this in pieces than all at once. |
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.
Looks good. It will be nice to have these building blocks.
I saw a few places where coverage claims things aren't tested. These are mostly in the error checking and methods with Default values.
Also, We should add some docstrings that at a minimum write the functional form of the utility function. I think this belongs as a docstring on each type.
ξ::Float64 | ||
end | ||
|
||
LogUtility() = LogUtility(1.0) |
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.
Untested
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.
This should get tested now.
|
||
function CRRAUtility(γ, ξ=1.0) | ||
if abs(γ - 1.0) < 1e-8 | ||
error("Your value for γ is very close to 1... Consider using LogUtility") |
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.
Untested.
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.
Should get tested now.
|
||
function CFEUtility(ϕ, ξ=1.0) | ||
if abs(ϕ - 1.0) < 1e-8 | ||
error("Your value for ϕ is very close to 1... Consider using LogUtility") |
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.
Untested.
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.
Should get tested now.
end | ||
|
||
# These defaults are pulled straight from Evans Phillips 2017 | ||
EllipticalUtility(;b=0.5223, μ=2.2926) = EllipticalUtility(b, μ) |
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.
Untested
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.
Should get tested now.
Can you rebase off master to get the fixes @Shunsuke-Hori made to the calls to Optim? That will get tests outside of this PR passing |
Actually, scratch that. I can see that these test pass b/c travis said the |
I think this is ready for review. Did you want me to rebase or is it ok? |
In this pull request, I introduce an abstract type
AbstractUtility
. I also include 4 concrete utility functions and their derivatives:LogUtility
,CRRAUtility
,CFEUtility
, andEllipticalUtility
-- The first two are typically used in modeling consumption utility and second two for labor utility.Additionally, the folder
modeltools
can be a placeholder for adding things like production functions etc... in the future.Example
@sglyon