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

Fix AdjustPrb for discrete portfolio choice. #391

Merged
merged 2 commits into from
Sep 29, 2019

Conversation

pkofod
Copy link
Contributor

@pkofod pkofod commented Sep 19, 2019

Fix #389

So there were some leftover lines from a different way of constructing the re-curving value function interpolation.

A thing I noticed while trying this out to be sure it worked. If you set the probability to 0.5 and look at the share of periods where the agents can adjust, it'll be closer to 0.6 than 0.5. It could maybe be interesting to ask students to calculate the empirical share, and comment. (The answer is that when a new agent is replacing an old one whose lifecycle ended or who died, a new agent will always get the choice of their initial portfolio which implies a slightly higher "can adjust" ratio than 0.5).

@@ -244,9 +242,6 @@ def _calcwFunc(AdjustPrb, AdjustCount, ShareNowCount, vFunc_adj, CRRA):
evVals = AdjustPrb*vFunc_adj[0][ShareIndex](evalgrid) + (1-AdjustPrb)*vFunc_adj[1][ShareIndex](evalgrid)
with np.errstate(divide='ignore', over='ignore', under='ignore', invalid='ignore'):
evValsNvrs = utility_inv(evVals,gam=CRRA)
evVals = np.insert(evVals, 0, 0.0)
evValsNvrs = np.insert(evVals, 0, 0.0)

Copy link
Member

@MridulS MridulS Sep 21, 2019

Choose a reason for hiding this comment

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

Yeah, this was exactly where the error was popping in from. If there was a divide by zero error (in case of AdjustPrb < 1) which was ignored by np.errstate there was a mismatch between the length of evVals and evValsNvrs

@MridulS MridulS merged commit cd9f24f into econ-ark:master Sep 29, 2019
@pkofod pkofod deleted the pkm/fixadjustprb branch September 30, 2019 18:17
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.

ConsPortfolioModel does not work with AdjustProb < 1
3 participants