Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Endogenous Bedarfsgemeinschaften #778

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

MImmesberger
Copy link
Collaborator

@MImmesberger MImmesberger commented Jul 6, 2024

Closes #763, #758, #622

Here is a DAG of this PR that I'll update if there are any changes:
dagitty-model-5

Code to reproduce DAG on DAGitty
dag {
bb="-10.618,-10.977,11.518,10.54"
"arbeitsl_geld_2_anspruchshöhe_m_fg" [pos="8.367,3.213"]
"gesamte_fg_in_einer_bg_günstiger" [pos="-3.290,-1.284"]
"kinderzuschl_anspruchshöhe_m_fg" [pos="-2.484,2.132"]
"wohngeld_anspruchshöhe_m_fg" [pos="-7.269,0.380"]
"wohngeld_kinderzuschl_größer_als_arbeitsl_geld_2_fg" [pos="6.305,-0.642"]
"wohngeld_kinderzuschl_günstiger" [pos="1.545,4.234"]
... [pos="-3.844,-5.780"]
.... [pos="6.535,-10.212"]
_transfereinkommen_getrennte_bg_eltern_kinder_bg [pos="-3.981,-3.369"]
_transfereinkommen_gleiche_bg_eltern_kinder_fg [pos="-6.941,3.767"]
alle_wohngeld_kinderzuschl_statt_arbeitsl_geld_2_fg [pos="1.596,6.628"]
arbeitsl_geld_2_eigenbedarf_gedeckt [pos="4.039,-6.277"]
arbeitsl_geld_2_eigenbedarf_gedeckt_und_kind_in_fg [pos="1.319,-9.605"]
arbeitsl_geld_2_m_bg [pos="-8.477,-6.364"]
bg_id [pos="5.689,-7.394"]
bg_id_endogen [pos="2.085,8.849"]
fg_id [pos="8.859,-5.764"]
hh_id [pos="8.505,-10.373"]
ist_kind_in_fg [pos="5.877,-2.773"]
kind [pos="-1.628,-4.934"]
kinder_mit_gedecktem_bedarf_in_fg [pos="1.061,-4.093"]
kinderzuschl_m_bg [pos="-8.377,-8.262"]
wohngeld_kinderzuschl_statt_arbeitsl_geld_2 [pos="-1.577,-7.824"]
wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen [pos="-5.330,5.869"]
wohngeld_kinderzuschl_vorrangig_bg [pos="0.115,0.214"]
wohngeld_m_wthh [pos="-8.553,-10.130"]
wthh_id [pos="7.796,-7.475"]
wthh_id_endogen [pos="10.258,8.306"]
"arbeitsl_geld_2_anspruchshöhe_m_fg" -> "wohngeld_kinderzuschl_größer_als_arbeitsl_geld_2_fg"
"gesamte_fg_in_einer_bg_günstiger" -> "wohngeld_kinderzuschl_günstiger"
"kinderzuschl_anspruchshöhe_m_fg" -> "wohngeld_kinderzuschl_größer_als_arbeitsl_geld_2_fg"
"kinderzuschl_anspruchshöhe_m_fg" -> _transfereinkommen_gleiche_bg_eltern_kinder_fg
"wohngeld_anspruchshöhe_m_fg" -> "wohngeld_kinderzuschl_größer_als_arbeitsl_geld_2_fg"
"wohngeld_anspruchshöhe_m_fg" -> _transfereinkommen_gleiche_bg_eltern_kinder_fg
"wohngeld_kinderzuschl_größer_als_arbeitsl_geld_2_fg" -> "wohngeld_kinderzuschl_günstiger"
"wohngeld_kinderzuschl_günstiger" -> wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen
... -> arbeitsl_geld_2_m_bg
... -> kinderzuschl_m_bg
.... -> wohngeld_m_wthh
_transfereinkommen_getrennte_bg_eltern_kinder_bg -> "gesamte_fg_in_einer_bg_günstiger"
_transfereinkommen_gleiche_bg_eltern_kinder_fg -> "gesamte_fg_in_einer_bg_günstiger"
alle_wohngeld_kinderzuschl_statt_arbeitsl_geld_2_fg -> bg_id_endogen
arbeitsl_geld_2_eigenbedarf_gedeckt -> "wohngeld_kinderzuschl_günstiger"
arbeitsl_geld_2_eigenbedarf_gedeckt -> arbeitsl_geld_2_eigenbedarf_gedeckt_und_kind_in_fg
arbeitsl_geld_2_eigenbedarf_gedeckt -> bg_id
arbeitsl_geld_2_eigenbedarf_gedeckt -> kinder_mit_gedecktem_bedarf_in_fg
arbeitsl_geld_2_eigenbedarf_gedeckt -> wthh_id
arbeitsl_geld_2_eigenbedarf_gedeckt_und_kind_in_fg -> wohngeld_kinderzuschl_statt_arbeitsl_geld_2
bg_id -> ...
fg_id -> bg_id
fg_id -> ist_kind_in_fg
hh_id -> wthh_id
hh_id -> wthh_id_endogen
ist_kind_in_fg -> "wohngeld_kinderzuschl_günstiger"
ist_kind_in_fg -> arbeitsl_geld_2_eigenbedarf_gedeckt_und_kind_in_fg
ist_kind_in_fg -> bg_id_endogen
kind -> kinder_mit_gedecktem_bedarf_in_fg
kinder_mit_gedecktem_bedarf_in_fg -> "gesamte_fg_in_einer_bg_günstiger"
kinder_mit_gedecktem_bedarf_in_fg -> "wohngeld_kinderzuschl_günstiger"
wohngeld_kinderzuschl_statt_arbeitsl_geld_2 -> arbeitsl_geld_2_m_bg
wohngeld_kinderzuschl_statt_arbeitsl_geld_2 -> kinderzuschl_m_bg
wohngeld_kinderzuschl_statt_arbeitsl_geld_2 -> wohngeld_m_wthh
wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen -> alle_wohngeld_kinderzuschl_statt_arbeitsl_geld_2_fg
wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen -> bg_id_endogen
wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen -> wthh_id_endogen
wohngeld_kinderzuschl_vorrangig_bg -> wohngeld_kinderzuschl_statt_arbeitsl_geld_2_endogen
wthh_id -> ....
}

@MImmesberger
Copy link
Collaborator Author

MImmesberger commented Jul 6, 2024

I'm not too happy with the current implementation because I needed to copy+paste a lot of code in regarding SGB II Vermögensgrenzen and KiZ calculation (we need them on fg and bg level). From a (very) quick first look it doesn't seem like we can move to individual-level calculation there, we should discuss this.

But it may be a good idea to postpone this to another PR (if its possible at all), this one is already quite complicated.

Copy link
Collaborator

@hmgaudecker hmgaudecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just skimmed through a couple of things to keep the conversation up!

src/_gettsim/groupings.py Outdated Show resolved Hide resolved
src/_gettsim/groupings.py Outdated Show resolved Hide resolved
CHANGES.md Show resolved Hide resolved
src/_gettsim/groupings.py Outdated Show resolved Hide resolved
src/_gettsim/transfers/benefit_checks/benefit_checks.py Outdated Show resolved Hide resolved
src/_gettsim/transfers/arbeitsl_geld_2/bedarf.py Outdated Show resolved Hide resolved
Copy link

codecov bot commented Jul 7, 2024

Codecov Report

Attention: Patch coverage is 95.76720% with 8 lines in your changes missing coverage. Please review.

Project coverage is 90.05%. Comparing base (ffbccf3) to head (8efe281).

Files Patch % Lines
src/_gettsim/groupings.py 87.87% 4 Missing ⚠️
...ettsim/transfers/kinderzuschl/kinderzuschl_eink.py 86.66% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #778      +/-   ##
==========================================
+ Coverage   89.69%   90.05%   +0.35%     
==========================================
  Files          53       53              
  Lines        3796     3951     +155     
==========================================
+ Hits         3405     3558     +153     
- Misses        391      393       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@MImmesberger
Copy link
Collaborator Author

Sorry that this comes super late: While working on the test files, I noticed a major bug that is not easy to fix and would lead to jumps in disposable income. The reason is that Kindergeldübertrag depends on the amount of Wohngeld, but the Kindergeldübertrag currently uses a "candidate Wohngeld" function as an input, not the actual amount.

This is not easy to fix inside the DAG. I think it doesn't make sense to introduce even more candidate functions to make this work given that we discussed to move to several GETTSIM calls in the future. Hence, I would vote for not merging this one. We can use the test files and the logic developed in this PR in the PR that tackles this.

@hmgaudecker hmgaudecker added the blocked Waits on other features. label Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Waits on other features.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BUG: Endogenous creation of bg_id
2 participants