iza-institute-of-labor-economics / gettsim

The GErman Taxes and Transfers SIMulator
https://gettsim.readthedocs.io/
GNU Affero General Public License v3.0
57 stars 33 forks source link

Move calculation of kinderzuschlag_max #321

Closed Eric-Sommer closed 2 months ago

Eric-Sommer commented 2 years ago

Current situation

In PR #267, we solved the new calculation for the maximum kinderzuschlag by setting the kinderzuschlag_max in policy_enviroment.py (link). While this works fine, this is not the place one would look for it.

Suggestion

by @mjbloemer :

Why not simply add a new year switch (two functions) there where ..bis_2020 is equal to the parameter and ..since_2021 is a function of the ExMin and KG parameters? Just another level of function composition instead of overwriting parameters?

hmgaudecker commented 2 years ago

The problem is that if it was placed in kinderzuschlag.py, it would become part of the DAG. That's why we put it where it is.

But I think this should actually happen! It is also a good example of the value of setting kinderzuschlag_max to null starting in 2021.

The function could just be (untested)

def kinderzuschlag_max(hh_id, kinderzuschlag_params, kindergeld_params):
    if "kinderzuschlag_max" in kinderzuschlag_params:
        out_scalar = kinderzuschlag_params["kinderzuschlag_max"]
    else:
        params["kinderzuschlag"]["kinderzuschlag_max"] = (
            params["kinderzuschlag"]["exmin"]["regelsatz"]["kinder"]
            + params["kinderzuschlag"]["exmin"]["kosten_der_unterkunft"]["kinder"]
            + params["kinderzuschlag"]["exmin"]["heizkosten"]["kinder"]
        ) / 12 - params["kindergeld"]["kindergeld"][1]

    return pd.Series(out_scalar, index=hh_id)

(stuff under else just taken from current function)

ChristianZimpelmann commented 2 years ago

Shouldn't it rather be:

if "kinderzuschlag_max" not in kinderzuschlag_params:

Eric-Sommer commented 2 years ago

Shouldn't it rather be:

if "kinderzuschlag_max" not in kinderzuschlag_params:

I agree. @mjbloemer is however right in pointing out that this leads to errors before 2004 when there is no [exmin] parameter. So maybe if "kinderzuschlag_max" not in kinderzuschlag_params and "exmin" in kinderzuschlag_params:

mjbloemer commented 2 years ago

My point was not about the exmin parameter, but that there is no Kinderzuschlag prior to 2005.

hmgaudecker commented 2 years ago

Shouldn't it rather be:

if "kinderzuschlag_max" not in kinderzuschlag_params:

Thanks! Almost. I fixed it above directly

hmgaudecker commented 2 years ago

My point was not about the exmin parameter, but that there is no Kinderzuschlag prior to 2005.

And you are completely right, of course. You're just too fast for me :wink:

I added that to GEP-04, we'll need to find a good way of handling such cases at the function level. The function kinderzuschlag_max should not be part of the DAG prior to the existence of kinderzuschlag.

See here, docs take a while to build, we probably committed too much today.

MImmesberger commented 2 months ago

Only part missing is #789. Hence, I'll close this one as completed.