econ-ark / HARK

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

ConsBequestModel and related example notebooks #1399

Closed dedwar65 closed 2 months ago

dedwar65 commented 2 months ago

Consider the two notebooks example_TerminalBequest.ipynb and example_AccidentalBequest.ipynb.

If you look at ConsBequestModel.py where the dictionaries used in these notebooks are defined are located, it says that the key difference between the respective dictionaries init_warm_glow and init_accidental_bequest is that ["BeqFac"] = 1.0.

However, if you go to the two notebooks and insert the following code immediately after the params variable are defined for each dictionary, you will see that a list of [1.0]'s is returned for both:

print(TerminalExample.BeqFac) or print(Agent.BeqFac) for the respective notebook.

This is particularly alarming, since the notebooks produce two different results (despite the fact that, upon close inspection, the two dictionaries are the same in the parameters that are supposed to make them different).

dedwar65 commented 2 months ago

Update: If you insert the command print(params["BeqFac"]) in the notebook example_TerminalBequest.ipynb where the dictionary init_warm_glow is used, you will get an error KeyError: 'BeqFac'. This also points to the issue: it seems that when the Bequest consumer type is constructed, it just assigns [1.0] if no value of ["BeqFac"] is specified. Intutitively, it should be [0.0] right ?

Ex. If I initialize a Bequest Consumer type with the standard init_lifecycle dictionary, it should set all relevant bequest parameters to 0. For whatever reason, the init_warm_glow dictionary is leading to an instance of the Bequest Consumer type to be initialized with [1.0] as its value for ["BeqFac"].

This is a one line fix in "ConsBequestModel.py" where the dictionary is defined. However, it may not prevent other issues like this showing up (i.e. it seems we need to find out what causes the default to be [1.0] and not [0.0] as opposed to just inserting init_warm_glow["BeqFac"] = [0.0]).