econ-ark / HARK

Heterogenous Agents Resources & toolKit
Apache License 2.0
315 stars 195 forks source link

Why does PerfForesightLabeled inherit from ConsIndShock? #1422

Closed mnwhite closed 3 weeks ago

mnwhite commented 3 weeks ago

The "labeled perfect foresight" model apparently inherits from IndShockConsumerType and thus expects a lot of information (about income shocks, etc) that has no meaning in the PF model. Why? I'm having a hard time updating the code because I need to get meaningless information into this class, or have it ignore that stuff.

alanlujan91 commented 3 weeks ago

because IndShockLabeledType needs to import from IndShockConsumerType and PerfForesightLabeled, and I thought this was a good way to avoid multiple inheritance, which I still don't understand very well.

If there is a better way to do it, then we should do that!

mnwhite commented 3 weeks ago

There's a better way. I am utterly baffled at how this class manages to initialize and run. It needs income shock parameters to be passed to it... but they're not in its default dictionary!

alanlujan91 commented 3 weeks ago

they are in the parent's default dictionary!

mnwhite commented 3 weeks ago

They are not! This class inherits from IndShockConsumerType, but uses the perfect foresight dictionary as its default:

image

I'll check in a moment, but I suspect the explanation is that all of the tests are using a custom dictionary, not the default one.

alanlujan91 commented 3 weeks ago

What is the default dictionary of IndShockConsumerType?

image
mnwhite commented 3 weeks ago

Ok, I see now. Hopefully I can work it out.

mnwhite commented 3 weeks ago

This is now fixed in #1410 by manually re-adding the (unexpectedly needed) constructors. It's wonky because update is being run multiple times during initialization. In the future, I think we should work toward update or construct not being called automatically during initialization, and have the user do it manually.