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

BUG: fg_id creation sensitive to order of adults #801

Open
MImmesberger opened this issue Nov 23, 2024 · 0 comments
Open

BUG: fg_id creation sensitive to order of adults #801

MImmesberger opened this issue Nov 23, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@MImmesberger
Copy link
Collaborator

MImmesberger commented Nov 23, 2024

Bug description

@JuergenWiemers drew my attention to the fact that our endogenous fg_id creation is sensitive to the order of adults in the data.

Consider the example input below. This is a 3-person household (parent + child and other adult in an Einstandsgemeinschaft with the parent). Note that the order of people in the household is a bit peculiar: First the childless adult, then the child, then the parent. Here, we would expect:

  fg_id:
    - 0
    - 0
    - 0
  bg_id:
    - 0
    - 0
    - 0
  eg_id:
    - 0
    - 1
    - 0

The result, however is:

  fg_id:
    - 0
    - 1
    - 0
  bg_id:
    - 0
    - 100
    - 0
  eg_id:
    - 0
    - 1
    - 0

This is due to the loop in our fg_id algorithm. There, the algorithm loops over p_ids in the data. For a given p_id, the loop starts with a candidate fg_id, assigns this fg_id to the current p_id, its Einstandspartner, and its children. The candidate fg_id then increases by 1 and the loop continues with the next p_id that does not have a matched fg_id yet.

The problem in the example below is that, the loop does not recognise the child as an fg_id member. In the first iteration, it assigns fg_id 0 to the first and last adult (Einstandspartner), but at this point, it does not know that the last adult has children in the household.

From what I see, this is also not solved by sorting the (internal) DataFrame properly in more complicated family structures (e.g. 2 adults and 2 children, each child is from a different partner).

Example Input

---
info:
  note: ''
  source: ''
inputs:
  provided:
    p_id:
      - 0
      - 1
      - 2
    alter:
      - 39
      - 13
      - 42
    hh_id:
      - 0
      - 0
      - 0
    p_id_einstandspartner:
      - 2
      - -1
      - 0
    p_id_elternteil_1:
      - -1
      - 2
      - -1
    p_id_elternteil_2:
      - -1
      - -1
      - -1
    eigenbedarf_gedeckt:
      - false
      - false
      - false
outputs:
  fg_id:
    - 0
    - 0
    - 0
  bg_id:
    - 0
    - 0
    - 0
  eg_id:
    - 0
    - 1
    - 0
@MImmesberger MImmesberger added the bug Something isn't working label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant