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

feat: use bhepop2 package for income assignment #243

Merged
merged 31 commits into from
Jul 15, 2024

Conversation

leo-desbureaux-tellae
Copy link
Collaborator

@leo-desbureaux-tellae leo-desbureaux-tellae commented Jun 18, 2024

Introduction of the Bhepop2 package for income assignment

data.income.municipality

The distributions DataFrame returned by data.income.municipality is now tagged by attribute and modality
Attributes describes a property present on the the population agents. A modality is a value taken by this attribute.
In Eqasim, we use two attributes:

  • "size", with modalities in ["1_pers", "2_pers", "3_pers", "4_pers", "5_pers_or_more"]
  • "family_comp", with modalities in ["Single_man", "Single_wom", "Couple_without_child", "Couple_with_child", "Single_parent", "complex_hh"]

New columns of the returned DataFrame are ["commune_id", "q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8", "q9", "attribute", "modality", "is_imputed", "is_missing", "reference_median"]
Global distributions (those that were returned in the previous version of municipality.py) are tagged with attribute and modality "all".

synthesis.population.income

New config option "income_assignation_method" (should it be "income_assignment_method" ?). This config allows choosing the method used to assign an income to population agents.
The former method is called via the config "uniform" (what should be the default config ?).
A new assignation method has been added, called via the config "bhepop2". This method uses the Bhepop2 package to match per attribute distributions instead of just matching the global one.

analysis.methods.income.compare_methods

A new analysis module has been added to compare the assignation methods. It can be run using the path analysis.methods.income.compare_methods.
This module generates plots comparing income distributions of each assignation method and the source distribution (here, Filosofi data).
This comparison is done per attribute. For instance, we compare the income distribution of individuals with attribute "family_comp" equal to "Single_parent" for the two methods, and see what method matches best the source distribution.
family_comp-Single_parent

Another output of this module is a table measuring the distance of each method to the source distribution, here again per attribute. This allows a more measurable comparison between assignation methods.

leo-desbureaux-tellae and others added 23 commits June 17, 2024 10:56
describe attribute modalities when giving attribute selection
municipality stage now returns a DataFrame containing income deciles per attributes in addition to the usual global deciles.
Two columns "attribute" and "modality" have been added to specify the related attribute and the value it takes (modality).
Attribute and modality for global deciles are "all".
Filter on "all" attribute and modality have been added where data.income.municipality were used.
merge municipality_attributes.py into municipality.py
move compare_methods.py to analysis/methods/income/
created a utils.py module in synthesis/population/income/ to store common functions
added test dataset and tests
---------

Co-authored-by: leo-desbureaux-tellae <[email protected]>
@Nitnelav Nitnelav requested a review from sebhoerl June 18, 2024 08:48
@sebhoerl
Copy link
Contributor

Hi! Thanks a lot, I'm at hEART this week and a bit busy the week after, but I'll look at it asap!

Copy link
Contributor

@sebhoerl sebhoerl left a comment

Choose a reason for hiding this comment

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

Thanks, I made a couple of minor comments, but this looks very good :)

docs/population.md Outdated Show resolved Hide resolved
docs/population.md Outdated Show resolved Hide resolved
documentation/info/collect.py Outdated Show resolved Hide resolved
synthesis/population/income/uniform.py Outdated Show resolved Hide resolved
synthesis/population/income/uniform.py Outdated Show resolved Hide resolved
synthesis/population/spatial/primary/candidates.py Outdated Show resolved Hide resolved
@sebhoerl
Copy link
Contributor

sebhoerl commented Jul 4, 2024

Thanks a lot, LGTM

@leo-desbureaux-tellae
Copy link
Collaborator Author

Issues from your first review are fixed ! Let me know if there is something more that needs changes.

@leo-desbureaux-tellae
Copy link
Collaborator Author

Resolved conflict in changelog

@sebhoerl
Copy link
Contributor

Thanks, looks all good, you can merge!

@Nitnelav
Copy link
Collaborator

Perfect, thank you very much @leo-desbureaux-tellae, thanks @sebhoerl for the review !! ⛵ 🚀

@Nitnelav Nitnelav merged commit f74bd98 into eqasim-org:develop Jul 15, 2024
2 checks passed
@leo-desbureaux-tellae leo-desbureaux-tellae deleted the feat/use_bhepop2 branch July 19, 2024 08:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants