from leximpact_survey_scenario.leximpact_survey_scenario import (
LeximpactErfsSurveyScenario,
)
import pandas as pd
import os
import plotly.graph_objects as go
config_files_directory = os.path.join(
os.path.dirname(os.path.dirname(os.getcwd())), ".config", "openfisca-survey-manager"
)year = 2019
input_individus_table = pd.HDFStore(
f"/home/cgl/data/leximpact-prepare-data_20230825/openfisca_erfs_fpr_{year}.h5"
)[f"individu_{year}"]input_individus_table.groupby("effectif_entreprise").count()| activite | age | categorie_salarie | categorie_non_salarie | chomage_brut | contrat_de_travail | date_naissance | heures_remunerees_volume | idfam | idfoy | idmen | noindiv | pensions_alimentaires_percues | pensions_invalidite | quifam | quifoy | quimen | rag | retraite_brute | ric | rnc | rpns_imposables | salaire_de_base | statut_marital | primes_fonction_publique | traitement_indiciaire_brut | idmen_original | idfoy_original | idfam_original | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| effectif_entreprise | |||||||||||||||||||||||||||||
| 0 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 | 72954 |
| 1 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 | 675 |
| 2 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 | 710 |
| 3 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 | 814 |
| 4 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 | 770 |
| 5 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 | 1396 |
| 7 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 | 473 |
| 8 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 | 525 |
| 9 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 | 440 |
| 10 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 | 10495 |
| 50 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 | 14421 |
| 500 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 | 5896 |
annee_calcul = 2024
variables_cotisations_salaries = [
"agirc_arrco_salarie",
]survey_scenario = LeximpactErfsSurveyScenario(
period=annee_calcul,
config_files_directory=config_files_directory,
)WARNING: no data for 2024, will took 2021
Données du scénario :
{'input_data_table_by_entity_by_period': {2024: {'individu': 'individu_2021', 'famille': 'famille_2021', 'foyer_fiscal': 'foyer_fiscal_2021', 'menage': 'menage_2021'}}, 'survey': 'leximpact_2021', 'config_files_directory': '/home/cgl/leximpact/leximpact-prepare-data/.config/openfisca-survey-manager'}
survey_scenario.simulations["baseline"].compute_pivot_table(
columns=["effectif_entreprise"],
period=annee_calcul,
aggfunc="count",
weighted=False,
)| effectif_entreprise | 0 | 1 | 2 | 3 | 4 | 5 | 7 | 8 | 9 | 10 | 50 | 500 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| weight | 72952.0 | 675.0 | 710.0 | 814.0 | 770.0 | 1395.0 | 473.0 | 525.0 | 440.0 | 10495.0 | 14419.0 | 5896.0 |
test = survey_scenario.simulations["baseline"].create_data_frame_by_entity(
[
"smic_proratise",
"salaire_de_base",
"traitement_indiciaire_brut",
"prime_fonction_publique",
],
period="2024",
merge=True,
)test["revenus"] = (
test.salaire_de_base
+ test.traitement_indiciaire_brut
+ test.traitement_indiciaire_brut
)
test["nb_smic"] = test.revenus / test.smic_proratisetest.loc[
(
test.salaire_de_base
+ test.traitement_indiciaire_brut
+ test.traitement_indiciaire_brut
)
< test.smic_proratise
]| person_id | salaire_de_base | smic_proratise | traitement_indiciaire_brut | idfam | famille_role | famille_position | idfoy | foyer_fiscal_role | foyer_fiscal_position | idmen | menage_role | menage_position | test | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 9800.976562 | 9900.125000 | 0.0 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0.989985 |
| 5 | 5 | 715.092712 | 722.326843 | 0.0 | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 | 0 | 0.989985 |
| 11 | 11 | 9324.247070 | 9418.572266 | 0.0 | 3 | 0 | 1 | 3 | 0 | 1 | 3 | 0 | 1 | 0.989985 |
| 12 | 12 | 4795.328125 | 4843.839355 | 0.0 | 4 | 0 | 0 | 4 | 0 | 0 | 4 | 0 | 0 | 0.989985 |
| 14 | 14 | 1696.592407 | 1713.755859 | 0.0 | 4 | 2 | 2 | 4 | 2 | 2 | 4 | 2 | 2 | 0.989985 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 109519 | 109519 | 13292.311523 | 13426.781250 | 0.0 | 54403 | 0 | 0 | 54403 | 0 | 0 | 50003 | 0 | 0 | 0.989985 |
| 109523 | 109523 | 6477.901855 | 6543.432129 | 0.0 | 54405 | 0 | 0 | 54405 | 0 | 0 | 50005 | 0 | 0 | 0.989985 |
| 109531 | 109531 | 21032.134766 | 21203.462891 | 0.0 | 54408 | 0 | 0 | 54408 | 0 | 0 | 50007 | 2 | 3 | 0.991920 |
| 109536 | 109536 | 9422.398438 | 9517.714844 | 0.0 | 54413 | 0 | 0 | 54413 | 0 | 0 | 50012 | 0 | 0 | 0.989985 |
| 109540 | 109540 | 251.954910 | 254.938858 | 0.0 | 54415 | 2 | 2 | 54415 | 2 | 2 | 50013 | 2 | 2 | 0.988295 |
12777 rows × 14 columns
actifs_occupes = test.loc[test["revenus"] > 0]
len(actifs_occupes)46642
12777 / 466420.27393765275931564
fig = go.Figure()
fig.add_trace(go.Histogram(x=actifs_occupes.loc[test["nb_smic"] < 4].test))Unable to display output for mime type(s): application/vnd.plotly.v1+json
- nous n’avons personne au forfait jour
survey_scenario.simulations["baseline"].compute_aggregate(
"cotisations_salariales", period=2021
) / 1e9--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Cell In[4], line 1 ----> 1 survey_scenario.simulations['baseline'].compute_aggregate("cotisations_salariales", period = "2021-01")/1e9 File ~/leximpact/leximpact-prepare-data/.venv/lib/python3.10/site-packages/openfisca_survey_manager/simulations.py:191, in compute_aggregate(simulation, variable, aggfunc, filter_by, period, missing_variable_default_value, weighted, alternative_weights, filtering_variable_by_entity) 187 log.debug("Variable {} not found. Assiging {}".format(variable, missing_variable_default_value)) 188 return missing_variable_default_value 190 weight = ( --> 191 simulation.calculate(weight_variable, period = period).astype(float) 192 if weight_variable else uniform_weight 193 ) 194 if weight_variable: 195 assert any(weight != 0), "Weights shall not be all zeroes" File ~/leximpact/leximpact-prepare-data/.venv/lib/python3.10/site-packages/openfisca_core/simulations/simulation.py:104, in Simulation.calculate(self, variable_name, period) 101 self.tracer.record_calculation_start(variable_name, period) 103 try: --> 104 result = self._calculate(variable_name, period) 105 self.tracer.record_calculation_result(result) 106 return result File ~/leximpact/leximpact-prepare-data/.venv/lib/python3.10/site-packages/openfisca_core/simulations/simulation.py:129, in Simulation._calculate(self, variable_name, period) 126 if variable is None: 127 raise errors.VariableNotFoundError(variable_name, self.tax_benefit_system) --> 129 self._check_period_consistency(period, variable) 131 # First look for a value already cached 132 cached_array = holder.get_array(period) File ~/leximpact/leximpact-prepare-data/.venv/lib/python3.10/site-packages/openfisca_core/simulations/simulation.py:336, in Simulation._check_period_consistency(self, period, variable) 330 return # For variables which values are constant in time, all periods are accepted 332 if ( 333 variable.definition_period == periods.DateUnit.YEAR 334 and period.unit != periods.DateUnit.YEAR 335 ): --> 336 raise ValueError( 337 "Unable to compute variable '{0}' for period {1}: '{0}' must be computed for a whole year. You can use the DIVIDE option to get an estimate of {0} by dividing the yearly value by 12, or change the requested period to 'period.this_year'.".format( 338 variable.name, period 339 ) 340 ) 342 if ( 343 variable.definition_period == periods.DateUnit.MONTH 344 and period.unit != periods.DateUnit.MONTH 345 ): 346 raise ValueError( 347 "Unable to compute variable '{0}' for period {1}: '{0}' must be computed for a whole month. You can use the ADD option to sum '{0}' over the requested period, or change the requested period to 'period.first_month'.".format( 348 variable.name, period 349 ) 350 ) ValueError: Unable to compute variable 'weight_individus' for period 2021-01: 'weight_individus' must be computed for a whole year. You can use the DIVIDE option to get an estimate of weight_individus by dividing the yearly value by 12, or change the requested period to 'period.this_year'.
(
survey_scenario.simulations["baseline"].compute_aggregate(
"pension_salarie", period=2021
)
/ 1e9
+ survey_scenario.simulations["baseline"].compute_aggregate(
"vieillesse_deplafonnee_salarie", period=2021
)
/ 1e9
+ survey_scenario.simulations["baseline"].compute_aggregate(
"vieillesse_plafonnee_salarie", period=2021
)
/ 1e9
)-55.88562783504803
DSS septembre 2023 : 306 Mds de cotisations brutes prévues pour 2024
- 191,079 Mds Secteur privé (62 %)
- 73,725 Mds Secteur public (24 %)
Pa risque (attention les pourcentages sont définis pour 2023, c’est de la projection de garder les mêmes pourcentage en 2024) : - 165,24 Mds Vieillesse (54 %) - 88,88 Mds Maladie (29 %) - 36,77 Mds Famille (12 %)
Chiffres 2021 (pour comparaison INES): - Total cotisations : 266 Mds dont : - Secteur privé : 161 Mds - Secteur public : 67 Mds - Par risque : - Vieillesse 143,64 Mds (54 %) - Maladie 77,14 Mds (29 %) - Famille 31,92 Mds (12 %) - AT-MP 13,3 Mds (5 %)
Cibles INES 2021
A la différence de la DSS INES ne prend pas les cotisations de la sécurité sociale mais l’ensemble des cotisations obligatoire. Cela fait notamment qu’il y a les cotisations pour les régimes de retraite complémentaire
Par risque : - Retraite : 230,4 Mds France entière 220,8 Mds champ INES (96%) - AT-MP : 14 Mds France entière 13,4 Mds champ INES (96 %) - Famille : 32 Mds France entière 30,6 Mds champ INES (96 %) - Santé : 77,3 Mds France entière 74,1 Mds champ INES (96 %)
–> Donc a priori il y a que les retraites où différences, du fait des retraites complémentaires
survey_scenario.simulations["baseline"].compute_aggregate("famille", period=2021) / 1e9-43.53067790772334
survey_scenario.simulations["baseline"].compute_aggregate(
"allegement_cotisation_allocations_familiales", period=2021
) / 1e99.437075381577886
(43.53 - 9.44) / 321.0653125
survey_scenario.simulations["baseline"].compute_aggregate(
"mmid_employeur", period=2021
) / 1e9-103.99570909984678
survey_scenario.simulations["baseline"].compute_aggregate(
"allegement_cotisation_maladie", period=2021
) / 1e925.170357021804
(104 - 25) / 77.31.0219922380336353
survey_scenario.simulations["baseline"].compute_aggregate(
"accident_du_travail", period=2021
) / 1e9-6.191984969497131