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

Allow risky return draws to be agent-specific. #1250

Merged
merged 3 commits into from
Apr 4, 2023

Conversation

Mv77
Copy link
Contributor

@Mv77 Mv77 commented Apr 4, 2023

Our current implementation of models with risky returns impose the restriction that, when simulating, a single economy-wide return is drawn every period.

This PR adds the option for the returns that are drawn in simulation to be agent-specific.

This is useful, for instance, if you are doing a monte-carlo simulation to find the average consumption at age 45 implied by your model. With the current restriction, there is some inefficiency in the fact that agents' lives are correlated through return draws. Drawing a different shock for every agent breaks this correlation, and (I think?) increases the efficiency of the estimator (for a given AgentCount and T_sim).

  • Tests for new functionality/models or Tests to reproduce the bug-fix in code.
  • Updated documentation of features that add new functionality.
  • Update CHANGELOG.md with major/minor changes.

Comment on lines +247 to +257
# Agent specific simulation
self.pcct.sim_common_Rriksy = False
self.pcct.initialize_sim()
self.pcct.simulate()
# Assety that all columns of Risky are not the same
self.assertFalse(
np.all(
self.pcct.history["Risky"]
== self.pcct.history["Risky"][:, 0][:, np.newaxis]
)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@sbenthall this is, technically, a stochastic test (its probability of failure is veeeery tiny). But I am not sure how else to test the fact that draws should not be the same for all agents. Any idea?

@@ -61,6 +61,11 @@ def __init__(self, verbose=False, quiet=False, **kwds):
if not hasattr(self, "PortfolioBisect"):
self.PortfolioBisect = False

# Boolean determines whether, when simulating a given time period,
# all agents will draw the same risky return factor (true by default)
if not hasattr(self, "sim_common_Rriksy"):
Copy link
Member

Choose a reason for hiding this comment

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

Rrisky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I like Rrisky because R is the return factor and risky is its characteristic. Rfree is Rfree and not Free. Is this a battle for another hill?

Copy link
Member

Choose a reason for hiding this comment

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

No, I mean it's misspelled. You spelled R-RIKsy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crap. You are right. Thanks!

@alanlujan91
Copy link
Member

This is cool! I guess we've treated |R as an aggregate shock, and this can make it an idiosyncratic shock? Would there be any sense in generalizing |R such that it can have an aggregate and an idiosyncratic component? Also with other shocks we are more explicit about Agg/Ind but not with this one.

@Mv77
Copy link
Contributor Author

Mv77 commented Apr 4, 2023

Yes, that might be a future direction that we could go in.

But my only goal here is to make it easier for me to get estimates of unconditional mean life-cycle profiles.
You could achieve what I want setting AgentCount=1 and T_sim = original_tsim * original_agentcount. But that's much much slower because of the efficiency gains of batch-evaluation of interpolators and random draws.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.03 🎉

Comparison is base (88eb36c) 73.27% compared to head (9dbf39a) 73.31%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1250      +/-   ##
==========================================
+ Coverage   73.27%   73.31%   +0.03%     
==========================================
  Files          76       76              
  Lines       12532    12548      +16     
==========================================
+ Hits         9183     9199      +16     
  Misses       3349     3349              
Impacted Files Coverage Δ
HARK/ConsumptionSaving/ConsRiskyAssetModel.py 40.74% <100.00%> (+0.59%) ⬆️
...ConsumptionSaving/tests/test_ConsPortfolioModel.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@llorracc llorracc merged commit a306caf into econ-ark:master Apr 4, 2023
@Mv77 Mv77 mentioned this pull request Apr 4, 2023
3 tasks
@llorracc
Copy link
Collaborator

llorracc commented Apr 5, 2023

These are deep issues. There is a use case for either way of doing it.

For instance, if you are interested in "history-contingent" beliefs a la Malmendier and Nagel, it is absolutely necessary for the returns to be at the aggregate level so that the "depression babies" all live through the experience of the stock market crashing (falling by 89 percent), perhaps inducing a scarring effect.

If you are interested in more generic issues like the interaction of life cycle profiles with macroeconomic dynamics, a good case can be made for agents to draw "risky return" shocks that are different for each person -- because you deliberately want to suppress Malmendier-Nagel kinds of phenomena as an annoyance instead of an issue.

Another case for allowing idiosyncratic risky returns is when we want to model entrepreneurs or firms. The firm or entrepreneur probably needs to experience firm-specific or entrepreneur-specific shocks, as well as aggregate shocks.

In any case, my goal is to have a framework that can accommodate all of these options. This is part of the reason I'm keen on building the models backwards. (That might be obscure, but it does have content).

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.

4 participants