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

script update of DemARKs to new ConsIndShockModel.py check_conditions… #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion notebooks/Alternative-Combos-Of-Parameter-Values.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"from copy import deepcopy\n",
"\n",
"import HARK # Prevents import error from Demos repo\n",
"from HARK.utilities import plotFuncs"
"from HARK.utilities import plot_funcs"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/Alternative-Combos-Of-Parameter-Values.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
from copy import deepcopy

import HARK # Prevents import error from Demos repo
from HARK.utilities import plotFuncs
from HARK.utilities import plot_funcs

# %% {"code_folding": [0, 4]}
# Import IndShockConsumerType
Expand Down
6 changes: 3 additions & 3 deletions notebooks/ChangeLiqConstr.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"source": [
"from copy import deepcopy\n",
"from HARK.ConsumptionSaving.ConsIndShockModel import KinkedRconsumerType\n",
"from HARK.utilities import plotFuncsDer, plotFuncs\n",
"from HARK.utilities import plot_funcs_der, plot_funcs\n",
"mystr = lambda number : \"{:.4f}\".format(number)\n",
"\n",
"import matplotlib.pyplot as plt"
Expand Down Expand Up @@ -67,7 +67,7 @@
"# Plot the results \n",
"plt.ylabel('Consumption c')\n",
"plt.xlabel('Market Resources m')\n",
"plotFuncs([KinkyExample.solution[0].cFunc],KinkyExample.solution[0].mNrmMin,5)"
"plot_funcs([KinkyExample.solution[0].cFunc],KinkyExample.solution[0].mNrmMin,5)"
]
},
{
Expand Down Expand Up @@ -121,7 +121,7 @@
"KinkyExampleTighten.solve()\n",
"\n",
"# Compare the two functions\n",
"plotFuncs([KinkyExample.solution[0].cFunc,KinkyExampleTighten.solution[0].cFunc],KinkyExampleTighten.solution[0].mNrmMin,5)"
"plot_funcs([KinkyExample.solution[0].cFunc,KinkyExampleTighten.solution[0].cFunc],KinkyExampleTighten.solution[0].mNrmMin,5)"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion notebooks/ChangeLiqConstr.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ notebooks:
dashboards:
---

What Happens To the Consumption Function When A Liquidity Constraint is Tightened?
What Happens To the Consumption Function When A Liquidity Constraint is Tightened?
6 changes: 3 additions & 3 deletions notebooks/ChangeLiqConstr.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# + {"code_folding": [0]}
from copy import deepcopy
from HARK.ConsumptionSaving.ConsIndShockModel import KinkedRconsumerType
from HARK.utilities import plotFuncsDer, plotFuncs
from HARK.utilities import plot_funcs_der, plot_funcs
mystr = lambda number : "{:.4f}".format(number)

import matplotlib.pyplot as plt
Expand All @@ -60,7 +60,7 @@
# Plot the results
plt.ylabel('Consumption c')
plt.xlabel('Market Resources m')
plotFuncs([KinkyExample.solution[0].cFunc],KinkyExample.solution[0].mNrmMin,5)
plot_funcs([KinkyExample.solution[0].cFunc],KinkyExample.solution[0].mNrmMin,5)
# -

# 'Market Resources' $M$ is the total amount of money (assets plus current income) available to the consumer when the consumption decision is made. Lower case $m = M/P$ is the ratio of $M$ to permanent income. Likewise, $c = C/P$ is the ratio of consumption to permanent income.
Expand All @@ -87,7 +87,7 @@
KinkyExampleTighten.solve()

# Compare the two functions
plotFuncs([KinkyExample.solution[0].cFunc,KinkyExampleTighten.solution[0].cFunc],KinkyExampleTighten.solution[0].mNrmMin,5)
plot_funcs([KinkyExample.solution[0].cFunc,KinkyExampleTighten.solution[0].cFunc],KinkyExampleTighten.solution[0].mNrmMin,5)
# -

# ### Discussion
Expand Down
2 changes: 1 addition & 1 deletion notebooks/FisherTwoPeriod.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"import numpy as np\n",
"\n",
"from HARK.ConsumptionSaving.ConsIndShockModel import PerfForesightConsumerType\n",
"from HARK.utilities import plotFuncsDer, plotFuncs\n",
"from HARK.utilities import plot_funcs_der, plot_funcs\n",
"mystr = lambda number : \"{:.3f}\".format(number)\n",
"\n",
"from ipywidgets import interact, interactive, fixed, interact_manual\n",
Expand Down
2 changes: 1 addition & 1 deletion notebooks/FisherTwoPeriod.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
import numpy as np

from HARK.ConsumptionSaving.ConsIndShockModel import PerfForesightConsumerType
from HARK.utilities import plotFuncsDer, plotFuncs
from HARK.utilities import plot_funcs_der, plot_funcs
mystr = lambda number : "{:.3f}".format(number)

from ipywidgets import interact, interactive, fixed, interact_manual
Expand Down
58 changes: 29 additions & 29 deletions notebooks/Gentle-Intro-To-HARK-Buffer-Stock-Model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"import HARK \n",
"from copy import deepcopy\n",
"mystr = lambda number : \"{:.4f}\".format(number)\n",
"from HARK.utilities import plotFuncs"
"from HARK.utilities import plot_funcs"
]
},
{
Expand Down Expand Up @@ -192,13 +192,13 @@
" 'addToTimeVary',\n",
" 'assignParameters',\n",
" 'cFunc_terminal_',\n",
" 'checkAIC',\n",
" 'checkCondition',\n",
" 'checkConditions',\n",
" 'check_AIC',\n",
" 'check_condition',\n",
" 'check_conditions',\n",
" 'checkElementsOfTimeVaryAreLists',\n",
" 'checkFHWC',\n",
" 'checkGICPF',\n",
" 'checkRIC',\n",
" 'check_FHWC',\n",
" 'check_GIC',\n",
" 'check_RIC',\n",
" 'checkRestrictions',\n",
" 'clearHistory',\n",
" 'cycles',\n",
Expand Down Expand Up @@ -557,16 +557,16 @@
"name": "stderr",
"output_type": "stream",
"text": [
"GPFPF = 0.984539 \n",
"GPFInd = 0.993777 \n",
"GPFAgg = 0.964848 \n",
"GPFRaw = 0.984539 \n",
"GPFNrm = 0.993777 \n",
"GPFAggLivPrb = 0.964848 \n",
"Thorn = APF = 0.994384 \n",
"PermGroFacAdj = 1.000611 \n",
"uInvEpShkuInv = 0.990704 \n",
"FVAF = 0.932054 \n",
"VAF = 0.932054 \n",
"WRPF = 0.213705 \n",
"DiscFacGPFIndMax = 0.972061 \n",
"DiscFacGPFAggMax = 1.010600 \n"
"DiscFacGPFNrmMax = 0.972061 \n",
"DiscFacGPFAggLivPrbMax = 1.010600 \n"
]
},
{
Expand Down Expand Up @@ -713,8 +713,8 @@
}
],
"source": [
"# plotFuncs([list],min,max) takes a [list] of functions and plots their values over a range from min to max\n",
"plotFuncs([IndShockExample.solution[0].cFunc,IndShockExample.solution_terminal.cFunc],0.,10.)"
"# plot_funcs([list],min,max) takes a [list] of functions and plots their values over a range from min to max\n",
"plot_funcs([IndShockExample.solution[0].cFunc,IndShockExample.solution_terminal.cFunc],0.,10.)"
]
},
{
Expand All @@ -739,16 +739,16 @@
"name": "stderr",
"output_type": "stream",
"text": [
"GPFPF = 0.984539 \n",
"GPFInd = 1.021965 \n",
"GPFAgg = 0.964848 \n",
"GPFRaw = 0.984539 \n",
"GPFNrm = 1.021965 \n",
"GPFAggLivPrb = 0.964848 \n",
"Thorn = APF = 0.994384 \n",
"PermGroFacAdj = 0.973012 \n",
"uInvEpShkuInv = 0.963379 \n",
"FVAF = 0.906347 \n",
"VAF = 0.906347 \n",
"WRPF = 0.213705 \n",
"DiscFacGPFIndMax = 0.919178 \n",
"DiscFacGPFAggMax = 1.010600 \n"
"DiscFacGPFNrmMax = 0.919178 \n",
"DiscFacGPFAggLivPrbMax = 1.010600 \n"
]
}
],
Expand Down Expand Up @@ -790,7 +790,7 @@
"\n",
"Perhaps the most interesting such condition is the [\"Growth Impatience Condition\"](http://econ.jhu.edu/people/ccarroll/Papers/BufferStockTheory/#GIC): If this condition is satisfied, the consumer's optimal behavior is to aim to achieve a \"target\" value of $m$, to serve as a precautionary buffer against income shocks.\n",
"\n",
"The tests can be invoked using the `checkConditions()` method:"
"The tests can be invoked using the `check_conditions()` method:"
]
},
{
Expand All @@ -802,21 +802,21 @@
"name": "stderr",
"output_type": "stream",
"text": [
"GPFPF = 0.984539 \n",
"GPFInd = 0.993777 \n",
"GPFAgg = 0.964848 \n",
"GPFRaw = 0.984539 \n",
"GPFNrm = 0.993777 \n",
"GPFAggLivPrb = 0.964848 \n",
"Thorn = APF = 0.994384 \n",
"PermGroFacAdj = 1.000611 \n",
"uInvEpShkuInv = 0.990704 \n",
"FVAF = 0.932054 \n",
"VAF = 0.932054 \n",
"WRPF = 0.213705 \n",
"DiscFacGPFIndMax = 0.972061 \n",
"DiscFacGPFAggMax = 1.010600 \n"
"DiscFacGPFNrmMax = 0.972061 \n",
"DiscFacGPFAggLivPrbMax = 1.010600 \n"
]
}
],
"source": [
"IndShockExample.checkConditions(verbose=True)"
"IndShockExample.check_conditions(verbose=True)"
]
}
],
Expand Down
10 changes: 5 additions & 5 deletions notebooks/Gentle-Intro-To-HARK-Buffer-Stock-Model.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
import HARK
from copy import deepcopy
mystr = lambda number : "{:.4f}".format(number)
from HARK.utilities import plotFuncs
from HARK.utilities import plot_funcs

# %% [markdown]
# ## The Consumer's Problem with Transitory and Permanent Shocks
Expand Down Expand Up @@ -219,8 +219,8 @@
IndShockExample.solve(verbose=True) # Verbose prints progress as solution proceeds

# %%
# plotFuncs([list],min,max) takes a [list] of functions and plots their values over a range from min to max
plotFuncs([IndShockExample.solution[0].cFunc,IndShockExample.solution_terminal.cFunc],0.,10.)
# plot_funcs([list],min,max) takes a [list] of functions and plots their values over a range from min to max
plot_funcs([IndShockExample.solution[0].cFunc,IndShockExample.solution_terminal.cFunc],0.,10.)

# %% [markdown]
# ## Changing Constructed Attributes
Expand Down Expand Up @@ -253,7 +253,7 @@
#
# Perhaps the most interesting such condition is the ["Growth Impatience Condition"](http://econ.jhu.edu/people/ccarroll/Papers/BufferStockTheory/#GIC): If this condition is satisfied, the consumer's optimal behavior is to aim to achieve a "target" value of $m$, to serve as a precautionary buffer against income shocks.
#
# The tests can be invoked using the `checkConditions()` method:
# The tests can be invoked using the `check_conditions()` method:

# %%
IndShockExample.checkConditions(verbose=True)
IndShockExample.check_conditions(verbose=True)
14 changes: 7 additions & 7 deletions notebooks/Gentle-Intro-To-HARK-PerfForesightCRRA.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"import HARK \n",
"from copy import deepcopy\n",
"mystr = lambda number : \"{:.4f}\".format(number)\n",
"from HARK.utilities import plotFuncs"
"from HARK.utilities import plot_funcs"
]
},
{
Expand Down Expand Up @@ -220,7 +220,7 @@
],
"source": [
"mPlotTop=10\n",
"plotFuncs(PFexample.solution[0].cFunc,0.,mPlotTop)"
"plot_funcs(PFexample.solution[0].cFunc,0.,mPlotTop)"
]
},
{
Expand Down Expand Up @@ -259,7 +259,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Yikes! Let's take a look at the bottom of the consumption function. In the cell below, set the bounds of the $\\texttt{plotFuncs}$ function to display down to the lowest defined value of the consumption function."
"Yikes! Let's take a look at the bottom of the consumption function. In the cell below, set the bounds of the $\\texttt{plot_funcs}$ function to display down to the lowest defined value of the consumption function."
]
},
{
Expand All @@ -284,7 +284,7 @@
"# YOUR FIRST HANDS-ON EXERCISE!\n",
"# Fill in the value for \"mPlotBottom\" to plot the consumption function from the point where it is zero.\n",
"mPlotBottom = 0. # You should replace 0. with the correct answer \n",
"plotFuncs(PFexample.solution[0].cFunc,mPlotBottom,mPlotTop)"
"plot_funcs(PFexample.solution[0].cFunc,mPlotBottom,mPlotTop)"
]
},
{
Expand Down Expand Up @@ -334,14 +334,14 @@
"NewExample.DiscFac = 0.90\n",
"NewExample.solve()\n",
"mPlotBottom = NewExample.solution[0].mNrmMin\n",
"plotFuncs([PFexample.solution[0].cFunc,NewExample.solution[0].cFunc],mPlotBottom,mPlotTop)"
"plot_funcs([PFexample.solution[0].cFunc,NewExample.solution[0].cFunc],mPlotBottom,mPlotTop)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"(Note that you can pass a list of functions to $\\texttt{plotFuncs}$ as the first argument rather than just a single function. Lists are written inside of [square brackets].)\n",
"(Note that you can pass a list of functions to $\\texttt{plot_funcs}$ as the first argument rather than just a single function. Lists are written inside of [square brackets].)\n",
"\n",
"Let's try to deal with the \"problem\" of massive human wealth by making another consumer who has essentially no future income. We can almost eliminate human wealth by making the permanent income growth factor $\\textit{very}$ small.\n",
"\n",
Expand Down Expand Up @@ -373,7 +373,7 @@
"# your lines here!\n",
"\n",
"# Compare the old and new consumption functions\n",
"plotFuncs([PFexample.solution[0].cFunc,NewExample.solution[0].cFunc],0.,10.)"
"plot_funcs([PFexample.solution[0].cFunc,NewExample.solution[0].cFunc],0.,10.)"
]
},
{
Expand Down
Loading