econ-ark / HARK

Heterogenous Agents Resources & toolKit
Apache License 2.0
332 stars 198 forks source link

Automate rescaling of parameters #995

Open sbenthall opened 3 years ago

sbenthall commented 3 years ago

Sometimes it's necessary to rescale parameters from annual to quarterly or some other timescale.

This is a coding pattern for doing this, but it's being applied one parameter at a time.

https://github.com/econ-ark/DistributionOfWealthMPC/blob/master/Code/SetupParamsCSTW.py#L103-L124

It would be better to have a function that did this adjustment for all parameters.

See #878

llorracc commented 3 years ago

The coding pattern this refers to applies only to permanent multiplicative growth factors. So, for example, the right way to convert a transitory shock from an annual to a quarterly frequency is different from the right way to convert a permanent shock. (Mortality is also assumed to be a permanent state, so the same method applies to survival probabilities!)

Just a warning that any code needs to be sure to explain that it is not a universal tool for time scale conversion.

sbenthall commented 3 years ago

That's a very good point! I hadn't thought of that.

What is the right way to convert a transitory shock from annual to quarterly frequency?

The REMARK code has these values pre-converted. https://github.com/econ-ark/DistributionOfWealthMPC/blob/master/Code/SetupParamsCSTW.py#L75-L79

I'm not sure how Dolo would deal with this problem.

llorracc commented 3 years ago

What we are doing in the REMARK is actually more complicated than a simple conversion (involving solving a problem called "time aggregation" also -- there's a whole appendix to the paper about it).

In the absence of the time aggregation problem, you can work out what needs to be done to the transitory shocks to convert them to different time scales by asking "what size shock for time scale 1/n would result in the sum of n such shocks having the variance we observe the annual object to have?" The problem with this is that it becomes nonsensical if you make "n" too large, like weekly or daily, because if the shocks are truly transitory (at the daily frequency, say), then 365 completely independent draws of the daily transitory shock are going to require a stupendously large variance in order to generate any meaningful variance when all 365 are averaged together to produce a yearly figure.

sbenthall commented 3 years ago

Hmm. Ok. I see now what it needed to adjust the Transitory shock standard deviation.

I believe that in this case, the mean will also need to be adjusted as well.

In the core HARK code, this mean is actually always 1. https://github.com/econ-ark/HARK/blob/master/HARK/ConsumptionSaving/ConsIndShockModel.py#L2295-L2305

I see this is also the case in the cstwMPC code: https://github.com/llorracc/cstwMPC/blob/master/Code/cstwMPC_MAIN.py#L126-L135

Am I missing something? Or do we need to change the HARK default income process to allow for changing shock means if we want to allow it to handle quarterly models?

sbenthall commented 3 years ago

Also... you mentioned an appendix about time aggregation. I have not yet been able to find that -- is it printed with the article? Would you have a link to that handy?

llorracc commented 3 years ago

I'm guessing you are making the reasonable assumption that, say, GDP for a year is the sum of the GDP for the four quarters of the year.

That is true. But economists always use "annual-rate" data, and that's how to think about what we are doing when we are solving a quarterly model. So the mean of the quarterly numbers at an annual rate is the same as the mean of the annual number. Same for monthly numbers (at an annual rate), etc. Bottom line is that the means are the same, so no we don't need to allow for changing means.

On Mon, Apr 5, 2021 at 12:07 PM Sebastian Benthall @.***> wrote:

Hmm. Ok. I see now what it needed to adjust the Transitory shock standard deviation.

I believe that in this case, the mean will also need to be adjusted as well.

In the core HARK code, this mean is actually always 1.

https://github.com/econ-ark/HARK/blob/master/HARK/ConsumptionSaving/ConsIndShockModel.py#L2295-L2305

I see this is also the case in the cstwMPC code:

https://github.com/llorracc/cstwMPC/blob/master/Code/cstwMPC_MAIN.py#L126-L135

Am I missing something? Or do we need to change the HARK default income process to allow for changing shock means if we want to allow it to handle quarterly models?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/econ-ark/HARK/issues/995#issuecomment-813475004, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK72ER74E7PPEK2PYGZDTHHN4JANCNFSM42M6AZ6A .

--

sbenthall commented 3 years ago

Let me see if I understand this. Just focusing on the forward simulation:

In each period:

When a period is a year, the transitory shock will correspond to an increase of (on average) 1 annual income-level to the market resource level.

When the period is a quarter, each period the agent's market resource level increases by (on average) 1 pLvl.

What isn't happening in the quarterly model is the agent is earning four times the annual income from the yearly model. What is happening is that the pLvl in the quarterly model represents quarterly income. Because it is a quarterly income level, the pLvl starts lower and grows more slowly. This change is represented in the reduced standard deviations of the permanent income shock.

Is that correct?

One other question that comes up for me as I try to think through this:

I must be missing something here.

sbenthall commented 3 years ago

Because it is a quarterly income level, the pLvl starts lower and grows more slowly. This change is represented in the reduced standard deviations of the permanent income shock.

I'm sorry -- I was incorrect about this, wasn't I? The changing income growth rate is captured in the reduced PermGroFac...?

llorracc commented 3 years ago

No. In LEVELS:

[image: B{t+1} = A{t} R]

you earn interest income on your assets from the prior year. B is beginning of period market wealth.

[image: P{t+1} = \Gamma P{t} \psi_{t+1}]

Permanent income grows by factor [image: \Gamma] on average, but that gets shocked by [image: \psi] which is on average 1.

[image: Y{t+1} = P{t+1} \theta_{t+1}]

Actual income is permanent income times a mean-one transitory shock

[image: M{t+1} = B{t+1} + Y_{t+1}]

Market resources are dollars of market wealth plus dollars of income.

When everything is normalized by the level of permanent income in the corresponding period, we get the equations we actually use:

[image: b{t+1} = a{t} (R/\Gamma \psi{t+1})] [image: m{t+1} = b{t+1} + \theta{t+1}]

Then you choose the RATIO of consumption to permanent income [image: c{t+1}] leading to the RATIO of end-of-period assets to permanent income [image: a{t+1}] and the cycle repeats.

The LEVEL of your market WEALTH B{t+1} is totally unaffected by the permanent shock to your income in period{t+1}. Your market RESOURCES are equal to your market wealth PLUS your income, so the LEVEL of market resources moves one-for-one with income. How much of that is still left at the end of period [image: t+1] depends on how much you consume.

So, if this doesn’t answer your questions, try again.

On Mon, Apr 5, 2021 at 1:27 PM Sebastian Benthall @.***> wrote:

Let me see if I understand this. Just focusing on the forward simulation:

In each period:

  • The permanent income grows multiplicatively by a mean 1 permanent shock
  • [Implicitly, the agent's non-normalized wealth level grows by this amount]*
  • A mean 1 transitory shock is added to the normalized market resources

When a period is a year, the transitory shock will correspond to an increase of (on average) 1 annual income-level to the market resource level.

When the period is a quarter, each period the agent's market resource level increases by (on average) 1 pLvl.

What isn't happening in the quarterly model is the agent is earning four times the annual income from the yearly model. What is happening is that the pLvl in the quarterly model represents quarterly income. Because it is a quarterly income level, the pLvl starts lower and grows more slowly. This change is represented in the reduced standard deviations of the permanent income shock.

Is that correct?

One other question that comes up for me as I try to think through this:

  • Suppose there is a large downward swing in permanent income level. Theoretically, at that point their wealth level takes a correspondingly steep dive, if it's being computed from a normalized asset level (aLvl = pLvl * aNrm). That seems strange -- why would a sudden reduction of income result in a reduced level of wealth?
  • It's not so simple because there is also a consumption step. Could the consumption be responsible for the (end of period) drop in wealth? The would require the agent to consumer more after a decline in income, which is counterintuitive.

I must be missing something here.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/econ-ark/HARK/issues/995#issuecomment-813519704, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKCK74BNPJA2LHCWO6LQA3THHXIDANCNFSM42M6AZ6A .

--

sbenthall commented 3 years ago

Thank you. That does help.

I was forgetting that what's driving the mean income change is \Gamma, which is adjusted as a permanent factor in the quarterly model, while the shock definitions are adding variance but not anything to the mean income values.

sbenthall commented 3 years ago

Do discount factors (beta) need to be adjusted if period frequency changes? What about risk aversion factors?

llorracc commented 3 years ago

Do discount factors (beta) need to be adjusted if period frequency changes?

Yes. If I discount an event one year in the future by 4 percent, then I discount an event one quarter in the future by 1 percent.

What about risk aversion factors?

No. Those are about how much I dislike not knowing what my circumstances will be in the future. The degree of uncertainty itself increases with the horizon (I have a better idea what things will be like tomorrow than what they will be like 10 years from now), but (in the model we are using) the degree to which I dislike each chunk of uncertainty is independent of how far away it is (except insofar as the discount factor or other aspects of the model interfere). So, relative risk aversion of 3 at the annual frequency corresponds to 3 at the quarterly, monthly, or daily frequency.

mnwhite commented 3 months ago

We can definitely add a new set of tools to the Calibration directory that does time conversions of various kinds.