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

age-varying distributions for shocks #1017

Closed
sbenthall opened this issue Jun 15, 2021 · 2 comments
Closed

age-varying distributions for shocks #1017

sbenthall opened this issue Jun 15, 2021 · 2 comments
Assignees
Milestone

Comments

@sbenthall
Copy link
Contributor

Consider the Adjust shock in risky asset models.

def get_Adjust(self):
"""
Sets the attribute Adjust as a boolean array of size AgentCount, indicating
whether each agent is able to adjust their risky portfolio share this period.
Uses the attribute AdjustPrb to draw from a Bernoulli distribution.
Parameters
----------
None
Returns
-------
None
"""
if not ("AdjustPrb" in self.time_vary):
self.shocks["Adjust"] = Bernoulli(
self.AdjustPrb, seed=self.RNG.randint(0, 2 ** 31 - 1)
).draw(self.AgentCount)
else:
Adjust = np.zeros(self.AgentCount) # Initialize shock array
for t in range(self.T_cycle):
these = t == self.t_cycle
N = np.sum(these)
if N > 0:
AdjustPrb = self.AdjustPrb[t - 1]
Adjust[these] = Bernoulli(
AdjustPrb, seed=self.RNG.randint(0, 2 ** 31 - 1)
).draw(N)
self.shocks["Adjust"] = Adjust

This is some complicated case-handling code that could be extracted into an age-varying distribution class and put into distribution.py.

Related to #1003 and #890

@sbenthall sbenthall self-assigned this Jun 15, 2021
@sbenthall sbenthall added this to the 1.0.0 milestone Jun 15, 2021
@sbenthall
Copy link
Contributor Author

I'll need the test case from #832 to complete the work on this.

Otherwise, it's quite easy.

@sbenthall sbenthall mentioned this issue Jun 16, 2021
3 tasks
@sbenthall
Copy link
Contributor Author

fixed by #1018

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

No branches or pull requests

1 participant