sbenthall / SHARKFin

Simulating Heterogeneous Agents with Finance
7 stars 5 forks source link

Initial configuration to better get at phase transition #256

Open sbenthall opened 1 year ago

sbenthall commented 1 year ago

There's something I've talked about with @mesalas that I would like to put down. It involves the configuration of several moving parts.

We are trying to get at the impact of the expectations parameters (attention and zeta) on our results. An issue is that other aspects of the model are dominating results. These other aspects include:

What would reduce these effects are:

So ideally, what we would do, I think, is:

mesalas commented 1 year ago

I had a discussion with Allan about how we should view the consumers. I have been seeing them as a sort of retail investors that trade in the market, but really we should be seeing them as a rather passive long term investor.

What I got from our discussion is that we expect them to do or affect the market much under normal conditions. However when the market does something unexpected (from the point of view of the consumers) they may start affecting the market.

sbenthall commented 1 year ago

Since simulation-based estimation of 'target wealth' isn't working, I've tried using an approach I think @llorracc suggested, which is to look at the intersection of the consumption function with another function of interest.

This code is in here: https://github.com/sbenthall/SHARKFin/blob/master/macro/steady_state_mNrm.py

Winging this for now, what I'm looking for is the intersection of:

The plot of this is interesting: image

Essentially:

In other words, there are two points of intersection. This is unexpected.

On the other hand, I could easily be measuring the wrong thing here. This does seem more promising an approach than trying to get the target wealth through simulation, since there may well be no target wealth at all. I'm sure an Economist could do a better job of this than I'm doing, hint hint @alanlujan91 .

llorracc commented 1 year ago

Seb,

The topic of when a target exists is basically entirely what the BufferStockTheory is all about. Furthermore, there's a dashboard whose specific purpose is to help people understand the main points of the paper, at econ-ark.org/materials; there is also a notebook that uses HARK to produce all the results of the paper.

Once you've familiarized yourself with those resources, I would be happy to respond, specifically, to points where you think any of them are unclear.

On Thu, Aug 10, 2023 at 11:26 AM Sebastian Benthall < @.***> wrote:

Since simulation-based estimation of 'target wealth' isn't working, I've tried using an approach I think @llorracc https://github.com/llorracc suggested, which is to look at the intersection of the consumption function with another function of interest.

This code is in here:

https://github.com/sbenthall/SHARKFin/blob/master/macro/steady_state_mNrm.py

Winging this for now, what I'm looking for is the intersection of:

  • the consumption function, cFunc(mNrm)
  • the expected gain to wealth between after-consuming aNrm and the market resources of the next period mNrm:
    • $(m - c) (\alpha \mathbb{E}[\eta] + (1 - \alpha)R) + 1$, where the transitory income shock is 1 based on our parameterization of the problem.

The plot of this is interesting: [image: image] https://user-images.githubusercontent.com/68752/259792159-a1756b36-8183-4abc-ab02-673e5b369f54.png

Essentially:

  • Resource poor agents will consume less than they expect to gain, to build wealth.
  • Resource rich agents will consume less than they expect to gain, because... well, I suppose there is no target wealth for this population.
  • There is a small region in which the agents will consume more than they expect to gain, in between these two regions.

In other words, there are two points of intersection. This is unexpected.

On the other hand, I could easily be measuring the wrong thing here. This does seem more promising an approach than trying to get the target wealth through simulation, since there may well be no target wealth at all. I'm sure an Economist could do a better job of this than I'm doing, hint hint @alanlujan91 https://github.com/alanlujan91 .

— Reply to this email directly, view it on GitHub https://github.com/sbenthall/SHARKFin/issues/256#issuecomment-1673446326, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK7YJKJHBTHGGRADJKQ3XUT4THANCNFSM6AAAAAA26TZUNA . You are receiving this because you were mentioned.Message ID: @.***>

--

sbenthall commented 1 year ago

@llorracc I do understand that this problem is in totally in your wheelhouse. And I am frequently referring back to the Bufferstock paper and looking for clues to help with this problem. I'm sure you could illuminate your Bufferstock paper for me in lots of ways.

However, I also understand that since we are using a Portfolio model with endogenous portfolio selection and risky returns, the results from your Bufferstock paper are not going to tell us the answer directly. You have said yourself that to do an analysis of the Portfolio model comparable to your Bufferstock paper would be its own standalone paper.

I don't think we need to have that kind of paper in hand to do the SPARK paper that we are working on, because with a simulation based study we have already abandoned the possibility of analytically tractable results. However, we still need to understand the behavior of the consumers, and luckily we should in principle be able to determine this by examining the solution objections and simulating them.

Naturally, in the writing we will connect what we're doing to your Bufferstock work.

Again, @alanlujan91 is active on this paper and a deeper specialist in this area. In our many research conversations he has clarified many of these points and I hope he'll engage on this issue now that he's at large and in charge.

One thing that occurs to me is that, if I'm not mistaken about this double-intersection point, then maybe we can use it as part of the narrative somehow. Something like:

If consumers deciding to accumulate winds up dragging shares out of the institutional investors and crashing the economy, that's a morality tale!

llorracc commented 1 year ago

OK, sorry if my previous email seemed snippy. Let's discuss tomororw

On Thu, Aug 10, 2023 at 1:45 PM Sebastian Benthall @.***> wrote:

@llorracc https://github.com/llorracc I do understand that this problem is in totally in your wheelhouse. And I am frequently referring back to the Bufferstock paper and looking for clues to help with this problem. I'm sure you could illuminate your Bufferstock paper for me in lots of ways.

However, I also understand that since we are using a Portfolio model with endogenous portfolio selection and risky returns, the results from your Bufferstock paper are not going to tell us the answer directly. You have said yourself that to do an analysis of the Portfolio model comparable to your Bufferstock paper would be its own standalone paper.

I don't think we need to have that kind of paper in hand to do the SPARK paper that we are working on, because with a simulation based study we have already abandoned the possibility of analytically tractable results. However, we still need to understand the behavior of the consumers, and luckily we should in principle be able to determine this by examining the solution objections and simulating them.

Naturally, in the writing we will connect what we're doing to your Bufferstock work.

Again, @alanlujan91 https://github.com/alanlujan91 is active on this paper and a deeper specialist in this area. In our many research conversations he has clarified many of these points and I hope he'll engage on this issue now that he's at large and in charge.

One thing that occurs to me is that, if I'm not mistaken about this double-intersection point, then maybe we can use it as part of the narrative somehow. Something like:

  • Start the consumers at the 'target wealth' implied by the first intersection point
  • Notice that if the consumers become wealthier than the second intersection point, their behavior changes and they begin accumulating.

If consumers deciding to accumulate winds up dragging shares out of the institutional investors and crashing the economy, that's a morality tale!

— Reply to this email directly, view it on GitHub https://github.com/sbenthall/SHARKFin/issues/256#issuecomment-1673646665, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK7YX6EBMLOZWXZYNCWDXUUM45ANCNFSM6AAAAAA26TZUNA . You are receiving this because you were mentioned.Message ID: @.***>

--

sbenthall commented 1 year ago

Helpful feedback from @llorracc in the notes below. Bottom line is that if we want the consumers to have finite target wealth, we might be able to get it if we adjust the parameters to make the consumers more impatient, and give them labor income uncertainty. We can break the link between the 'lucas price' parameters (discount factor, risk aversion) and consumers if necessary (it may even be advised, because 'lucas pricers' are 'poised').

Handing this off to @alanlujan91 until we can all meet in Switzerland about this.

image

I note:

image

alanlujan91 commented 1 year ago

866c12ba-ad02-4149-b9f6-5fb20581fe17

Below zero, E[m'] expected cash on hand tomorrow is greater than cash today. Above zero, coh today is greater than what you expect to have tomorrow.

sbenthall commented 1 year ago

Cool - -what's the x axis there? market resources?

sbenthall commented 1 year ago

Thanks for confirming this @alanlujan91

I think we have our new course of action settled.

We have two points of intersection on that plot, $x_0$ and $x_1$.

For $m < x_1$, there is a region of attraction around point $x_0$. $x_0$ is the closest thing that we have to an equilibrium point. If the consumers stay in this region, then they will have finite target wealth and the number of risky shares held by the consumers should stay finite.

For $m > x_1$, then in expectation the consumers start to accumulation infinite wealth. We know that in this case, the consumers collect all the risky shares from the institutional investors and break the market.

If we initialize the consumers with market resources $x_0$, then we have a story about how the system is starting in equilibrium. We would expect market crashes to come if and only if endogenous behavior or exogenous shocks push the system out of the region of attraction.

What I don't think we know yet, which would be nice to know, is if in the USUAL conditions the ergodic distribution is settled around this point of attraction, or if the exogenous shocks push the system into the second regime. If the latter is the case, we don't really have the equilibrium it looks like we do.

Is there a way to test for this either analytically or numerically given the model?

sbenthall commented 1 year ago

Ok, I've been analyzing this a bit more.

Consider the two points of intersection $x_0$ and $x_1$. The first is the attractor of the attraction region for mNrm. The second is the boundary of the attraction region for mNrm.

The good news is that given the current configuration, if we start wealth close to $x0$, then there is indeed an equilibrium distribution of wealth. It looks like this: image

We can divide the population up into the 'upper' region, for whom mNrm > $x_1$, the 'middle' region for whom $x_0$ < mNrm < $x_1$, and the lower region for whom mNrm < $x_0$.

Essentially, what happens (here, assuming idiosyncatic risky shocks) is that some percentage of the population escapes the attractor region and begins accumulating, but the rest of the population remains in the attractor region (the middle and lower sections).

image

The total percentage of resources owned by each 'class' is also stable.

image

The reason why the 'upper' class doesn't just keep accumulating ad infinitum disrupting the equilibrium distribution of wealth is that, in this configuration, we have only a ~.995 chance of survival. (We are using quarterly numbers here). So, the rich get richer, but then they die. And in this version of the simulation (which is done just using HARK, with no SHARKFin stuff added), their extra wealth just disappears.

Theoretically, we could move forward with the SHARKFin simulation by choosing a starting wealth distribution reflective of the equilibrium wealth distribution, and proceeding with the experiment. There is one small and one large obstacle to this.

The small problem is that the equilibrium wealth distribution is not exactly log-normal. It's got a funky shape. If we use the HARK distribution classes, we will be getting only close-to-equilibrium, not true-equilibrium, starting wealth.

The larger problem is that I think we've managed to forget to factor mortality into both the Lucas pricing equation (including mortality rate as part of effective discount factor) and the way SHARKFin handles risky asset ownership (because agents that die do not immediately sell off their assets to the broker; there may be a bug where agents that accumulate and then die maintain some inaccurate record of owned shares?).

You might think the easy answer is to just turn off mortality entirely. But then the effective discount rate of the HARK agents gets closer to 1, and their solution changes, so they no longer have an attractor region of wealth.

Basically, we haven't been thinking through how mortality of agents matters in our model, and we have to answer those questions.

llorracc commented 1 year ago

it is a theorem that there is no equilibrium for wealth or the wealth-to-income ratio in the perfect foresight model for consumers with infinite lifetimes and no death-and-replacement.

On Thu, Oct 12, 2023 at 11:57 AM Sebastian Benthall < @.***> wrote:

Ok, I've been analyzing this a bit more.

Consider the two points of intersection $x_0$ and $x_1$. The first is the attractor of the attraction region for mNrm. The second is the boundary of the attraction region for mNrm.

The good news is that given the current configuration, if we start wealth close to $x0$, then there is indeed an equilibrium distribution of wealth. It looks like this: [image: image]

We can divide the population up into the 'upper' region, for whom mNrm > $x_1$, the 'middle' region for whom $x_0$ < mNrm < $x_1$, and the lower region for whom mNrm < $x_0$.

Essentially, what happens (here, assuming idiosyncatic risky shocks) is that some percentage of the population escapes the attractor region and begins accumulating, but the rest of the population remains in the attractor region (the middle and lower sections).

[image: image] https://user-images.githubusercontent.com/68752/274655045-bf6ab79a-d476-4b08-8eca-b855b0d6c9bc.png

The total percentage of resources owned by each 'class' is also stable.

[image: image] https://user-images.githubusercontent.com/68752/274655245-51f41d90-a982-44c3-9844-4458da3dc3c0.png

The reason why the 'upper' class doesn't just keep accumulating ad infinitum disrupting the equilibrium distribution of wealth is that, in this configuration, we have only a ~.995 chance of survival. (We are using quarterly numbers here). So, the rich get richer, but then they die. And in this version of the simulation (which is done just using HARK, with no SHARKFin stuff added), their extra wealth just disappears.

Theoretically, we could move forward with the SHARKFin simulation by choosing a starting wealth distribution reflective of the equilibrium wealth distribution, and proceeding with the experiment. There is one small and one large obstacle to this.

The small problem is that the equilibrium wealth distribution is not exactly log-normal. It's got a funky shape. If we use the HARK distribution classes, we will be getting only close-to-equilibrium, not true-equilibrium, starting wealth.

The larger problem is that I think we've managed to forget to factor mortality into both the Lucas pricing equation (including mortality rate as part of effective discount factor) and the way SHARKFin handles risky asset ownership (because agents that die do not immediately sell off their assets to the broker; there may be a bug where agents that accumulate and then die maintain some inaccurate record of owned shares?).

You might think the easy answer is to just turn off mortality entirely. But then the effective discount rate of the HARK agents gets closer to 1, and their solution changes, so they no longer have an attractor region of wealth.

Basically, we haven't been thinking through how mortality of agents matters in our model, and we have to answer those questions.

— Reply to this email directly, view it on GitHub https://github.com/sbenthall/SHARKFin/issues/256#issuecomment-1759905065, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK77OSGRXPJABPWU6MNDX7AHNJANCNFSM6AAAAAA26TZUNA . You are receiving this because you were mentioned.Message ID: @.***>

--

sbenthall commented 1 year ago

ok @llorracc but what about if there is risk in labor and/or returns? And, beyond that, portfolio allocation?

If there isn't a theorem for this already it would be pretty easy to establish it one way or another given the current tools and computing power available.

llorracc commented 1 year ago

sorry, I thought you were still plotting the perfect foresight model.

Yes, when there is labor income risk, you should get a nondegenerate and ergodic distribution, as long as the Growth Impatience Condition holds. (I've not bothered to derive the exact version of the GIC in the case with risky returns, but think I know how to do it).

On Thu, Oct 12, 2023 at 12:21 PM Sebastian Benthall < @.***> wrote:

ok @llorracc https://github.com/llorracc but what about if there is risk in labor and/or returns? And, beyond that, portfolio allocation?

If there isn't a theorem for this already it would be pretty easy to establish it one way or another given the current tools and computing power available.

— Reply to this email directly, view it on GitHub https://github.com/sbenthall/SHARKFin/issues/256#issuecomment-1759949443, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK76NOHGKD4NF6NSIITLX7AKIDANCNFSM6AAAAAA26TZUNA . You are receiving this because you were mentioned.Message ID: @.***>

--

sbenthall commented 1 year ago

The context here is:

sbenthall commented 9 months ago

@alanlujan91 's made the call -- we are bringing back in labor income uncertainty.

@alanlujan91 -- what do you think we should do about mortality?

sbenthall commented 9 months ago

@alanlujan91 -- what do you think we should do about unemployment probability?

In general, it looks like the default dashboard uses the full suite of 'default' HARK values. These seem to complicate the story we're telling. But when I've tried turning some of these 'off', I get errors in the HARK solver.

{'AdjustPrb': 1.0,
 'AgentCount': 10000,
 'BoroCnstArt': 0.0,
 'CRRA': 6,
 'CubicBool': False,
 'DiscFac': 0.9,
 'DiscreteShareBool': False,
 'IncUnemp': 0.3,
 'IncUnempRet': 0.0,
 'LivPrb': [0.98],
 'MaxKinks': 400,
 'NewbornTransShk': False,
 'PerfMITShk': False,
 'PermGroFac': [1.01],
 'PermGroFacAgg': 1.0,
 'PermShkCount': 7,
 'PermShkStd': [0.1],
 'Rfree': 1.03,
 'RiskyAvg': 1.08,
 'RiskyCount': 5,
 'RiskyStd': 0.2,
 'ShareCount': 25,
 'T_age': None,
 'T_cycle': 1,
 'T_retire': 0,
 'TranShkCount': 7,
 'TranShkStd': [0.1],
 'UnempPrb': 0.05,
 'UnempPrbRet': 0.005,
 'aNrmInitMean': 0.0,
 'aNrmInitStd': 1.0,
 'aXtraCount': 200,
 'aXtraExtra': [None],
 'aXtraMax': 100,
 'aXtraMin': 0.001,
 'aXtraNestFac': 1,
 'cycles': 1,
 'neutral_measure': False,
 'pLvlInitMean': 0.0,
 'pLvlInitStd': 0.0,
 'sim_common_Rrisky': True,
 'tax_rate': 0.0,
 'vFuncBool': False}

I've added something to the dashboard that produces the target wealth numerically. https://github.com/sbenthall/SHARKFin/blob/master/macro/dashboard_default.ipynb

I'm also working on a separate notebook for displaying target wealth over a grid of values, but am running into challenges related to these basic ones about our simulation configuration.

sbenthall commented 9 months ago

The issue I'm getting seems to depend on setting the PermGroFac to 1.0, which is definitely something we want to do. (We don't want correlations in permanent income!)

https://github.com/econ-ark/HARK/issues/1376

sbenthall commented 9 months ago

My mistake -- I was setting PermGroFac to 0.0. Silly. Ok, but we still need to settle other starting config details.

alanlujan91 commented 9 months ago

Mortality: Agents should perhaps think they are not infinitely lived: LivPrb = 0.98 or whichever the default is. However, agents should not actually die during simulation, they just believe they could and this affects their portfolio choice.

Unemployment: Again, these beliefs should inform the agent's decision, and I think we describe this as being more "realistic". At the end of the day, Unemployment just means a much lower income shock, since the replacement factor is 0.3.

PermGroFac: Correct, we should set this to 1. Which means permanent income has no drift.

sbenthall commented 9 months ago

On consideration: LivPrb = 1. UnEmp = none