{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# User Guide\n", "\n", "The Euromod Conector is a Python library providing tools for running simulations and interacting with the tax-benefit microsimulation model [EUROMOD](https://euromod-web.jrc.ec.europa.eu \"https://euromod-web.jrc.ec.europa.eu\"). \n", "\n", "## Installation\n", "The Euromod Connector can be installed from [PyPi](https://test.pypi.org/project/euromod/) using _pip_:\n", "```bash\n", "$ pip install euromod\n", "```\n", "\n", "### Requirements\n", "In order to run the model, we require two components: 1) the model (coded policy rules), and 2) the input microdata with the variables that respect the EUROMOD naming conventions.\n", "For more information, please, read the sections \"Model\" and \"Input microdata\" on the [Download Euromod](https://euromod-web.jrc.ec.europa.eu/download-euromod \"https://euromod-web.jrc.ec.europa.eu/download-euromod\") web page." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Running and navigating the model\n", "The euromod package is object oriented and evolves around using the Model class that loads a representation of the EUROMOD model. This can be imported as follows:" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from euromod import Model" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an object of the `Model` class by passing the path to the EUROMOD project: " ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Model\n", "------------------------------\n", "\t countries: 28 elements\n", "\t extensions: 11 elements\n", "\t model_path: 'C:\\\\EUROMOD_RELEASES_I6.0+'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod=Model(r\"C:\\EUROMOD_RELEASES_I6.0+\")\n", "mod" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that every object that is related to the EUROMOD project comes with an informative description. Here we can see that the model has 3 relevant attributes to the user:\n", "- countries\n", "- extensions\n", "- model_path\n", " \n", "The countries and extensions attributes contain elements of the respective objects. If we take a look at `countries`:" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: AT \n", "1: BE \n", "2: BG \n", "3: CY \n", "4: CZ \n", "5: DE \n", "6: DK \n", "7: EE \n", "8: EL \n", "9: ES \n", "10: FI\n", "11: FR\n", "12: HR\n", "13: HU\n", "14: IE\n", "15: IT\n", "16: LT\n", "17: LU\n", "18: LV\n", "19: MT\n", "20: NL\n", "21: PL\n", "22: PT\n", "23: RO\n", "24: SE\n", "25: SI\n", "26: SK\n", "27: SL" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `countries` attirbute is a container storing the Country objects nesting the country-specific tax-benefit `policies` and `systems`. We see indeed that the euromod model contains 28 countries. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{note} \n", "The elements in an attribute of type Container can be accessed by indexing the attribute with the element position.\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In a similar fashion we can look what kind of extensions are stored in the model. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{tip} \n", "The countries container can be indexed by both the number of the element and the country shortcode. \n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Let us take a look at Sweden:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Country\n", "------------------------------\n", "\t datasets: 27 elements\n", "\t extensions: 12 elements\n", "\t local_extensions: COVID\n", "\t name: 'SE'\n", "\t policies: 26 elements\n", "\t systems: 18 elements" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we see again an informative representation of the `Country` object, which contains several attributes that can be accessed. In order to simulate a system we run a specific System object. We can obtain the systems for Sweden as follows:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: SE_2006 \n", "1: SE_2007 \n", "2: SE_2008 \n", "3: SE_2009 \n", "4: SE_2010 \n", "5: SE_2011 \n", "6: SE_2012 \n", "7: SE_2013 \n", "8: SE_2014 \n", "9: SE_2015 \n", "10: SE_2016\n", "11: SE_2017\n", "12: SE_2018\n", "13: SE_2019\n", "14: SE_2020\n", "15: SE_2021\n", "16: SE_2022\n", "17: SE_2023" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].systems" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{tip} \n", "The systems container can be indexed by both the number of the element and the system name. \n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Running a simulation\n", "\n", "In order to run the tax system we need a dataset that fits the requirement to use. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{seealso} \n", "See Other important euromod objects on what datasets are configured and how.\n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you know already which dataset to use you can simply load the data and run the model as follows:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Simulation for system SE_2021 with dataset SE_2021_b1 finished.\n" ] }, { "data": { "text/plain": [ "------------------------------\n", "Simulation\n", "------------------------------\n", "\t constantsToOverwrite: {}\n", "\t errors: []\n", "\t output_filenames: ['se_2021_std.txt']\n", "\t outputs: Pandas DataFrame of 240 variables and 21671 observations." ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "import pandas as pd\n", "data=pd.read_csv(r\"C:\\EUROMOD_RELEASES_I6.0+\\Input\\SE_2021_b1.txt\",sep=\"\\t\")\n", "out_baseline = mod.countries[\"SE\"].systems[\"SE_2021\"].run(data,\"SE_2021_b1\")\n", "out_baseline" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [ "remove-input" ] }, "outputs": [], "source": [ "pd.set_option('display.max_rows', 11, 'display.max_columns',7)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that the run function here takes the mandatory argument `dataset_id`, which in our case is SE_2021_b1. This is necessary such that EUROMOD can apply the dataset specific logic with respect to setting default values and uprating. This returned us a Simulation object with multiple attributes. The one of interest here is outputs, which contains the outputdataset(s) returned by the microsimulation model:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
idhhidpersonidmother...tu_bho_se_IsDependentChildtu_bho_se_IsLoneParenttu_bho_se_IsPartner
0200.020001.00.0...0.00.00.0
1300.030001.00.0...0.00.00.0
2300.030002.00.0...0.00.01.0
3500.050001.00.0...0.00.00.0
4500.050002.00.0...0.00.01.0
........................
216661936500.0193650002.00.0...0.00.01.0
216671936800.0193680001.00.0...0.00.01.0
216681936800.0193680002.00.0...0.00.00.0
216691936800.0193680003.0193680002.0...1.00.00.0
216701936800.0193680004.0193680002.0...1.00.00.0
\n", "

21671 rows × 240 columns

\n", "
" ], "text/plain": [ " idhh idperson idmother ... tu_bho_se_IsDependentChild \\\n", "0 200.0 20001.0 0.0 ... 0.0 \n", "1 300.0 30001.0 0.0 ... 0.0 \n", "2 300.0 30002.0 0.0 ... 0.0 \n", "3 500.0 50001.0 0.0 ... 0.0 \n", "4 500.0 50002.0 0.0 ... 0.0 \n", "... ... ... ... ... ... \n", "21666 1936500.0 193650002.0 0.0 ... 0.0 \n", "21667 1936800.0 193680001.0 0.0 ... 0.0 \n", "21668 1936800.0 193680002.0 0.0 ... 0.0 \n", "21669 1936800.0 193680003.0 193680002.0 ... 1.0 \n", "21670 1936800.0 193680004.0 193680002.0 ... 1.0 \n", "\n", " tu_bho_se_IsLoneParent tu_bho_se_IsPartner \n", "0 0.0 0.0 \n", "1 0.0 0.0 \n", "2 0.0 1.0 \n", "3 0.0 0.0 \n", "4 0.0 1.0 \n", "... ... ... \n", "21666 0.0 1.0 \n", "21667 0.0 1.0 \n", "21668 0.0 0.0 \n", "21669 0.0 0.0 \n", "21670 0.0 0.0 \n", "\n", "[21671 rows x 240 columns]" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "out_baseline.outputs[0]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Navigating the model\n", "The `Model` object actually contains a full representation of the model that can be accessed using it's attributes. The implementation in Python mimicks the hierarchical structure of the EUROMOD User Interface. A full description of the available types can be found in the API reference. \n", "\n", "#### The spine\n", "The spine of EUROMOD is what represents the series of calculations with to respect taxes and benefits.\n", "The spine consists out of three hierarchically ordered elements:\n", "- Policy\n", " - Function\n", " - Parameter\n", " \n", "The connector mimmicks this hierarchical implementation through an object-oriented representation. The three hierarchical elements are defined on the Country level and implemented on the System level.\n", "\n", "Let us take a look at the policies, which are an attribute of the `Country` object:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: setdefault_se | | DEF: SET DEFAULT \n", "1: uprate_se | | DEF: UPRATING FACTORS \n", "2: ConstDef_se | | DEF: CONSTANTS \n", "3: IlsDef_se | | DEF: INCOME CONCEPTS (standardized) \n", "4: IlsUDBdef_se | | DEF: INCOME CONCEPTS (UDB) \n", "5: ildef_se | | DEF: INCOME CONCEPTS (non-standardized) \n", "6: random_se | | DEF: Random assignment \n", "7: TransLMA_se | | DEF: Modelling labour market transitions (DO NOT S ... \n", "8: tudef_se | | DEF: ASSESSMENT UNITS \n", "9: yem_se | (with switch set for MWA) | DEF: minimum wage \n", "10: neg_se | | DEF: recode negative self-employment income to zer ... \n", "11: yemcomp_se | | BEN: wage compensation scheme COVID-19 (ONLY WORK ... \n", "12: bunct_se | | BEN: unemployment benefit (contributory) \n", "13: bfapl_se | (with switch set for PBE) | BEN: Parental leave benefit \n", "14: bpa_se | (with switch set for PBE) | BEN: Special leave days other parent (10 days) \n", "15: tscee_se | | SIC: Employee Social Insurance contribution \n", "16: tscer_se | | SIC: Employer Social Insurance contribution \n", "17: tscse_se | | SIC: Self-employed Social Insurance contribution \n", "18: tin_se | | TAX: Personal Income tax \n", "19: tinkt_se | | TAX: Tax on Capital Income \n", "20: bch_se | | BEN: Child benefit \n", "21: bho_se | | BEN: Housing allowance \n", "22: bhope_se | | BEN: Housing allowance for pensioners \n", "23: bsamt_se | | BEN: Social Assistance (means-tested) \n", "24: output_std_se | | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "25: output_std_hh_se | | DEF: STANDARD OUTPUT HOUSEHOLD LEVEL " ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].policies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As one can see the `policies` attribute is a Container object therefor it's elements, which are of the type Policy here, are accessible by indexing:" ] }, { "cell_type": "code", "execution_count": 32, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Policy\n", "------------------------------\n", "\t ID: '01f1c7ff-3b6d-4191-bc71-bb86db5603d6'\n", "\t comment: 'BEN: unemployment benefit (contributory)'\n", "\t extensions: 0 elements\n", "\t functions: 16 elements\n", "\t name: 'bunct_se'\n", "\t order: '13'\n", "\t private: 'no'\n", "\t spineOrder: '13'" ] }, "execution_count": 32, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].policies[12]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The implementation of a policy is accessible through the System object." ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: setdefault_se | on | DEF: SET DEFAULT \n", "1: uprate_se | on | DEF: UPRATING FACTORS \n", "2: ConstDef_se | on | DEF: CONSTANTS \n", "3: IlsDef_se | on | DEF: INCOME CONCEPTS (standardized) \n", "4: IlsUDBdef_se | on | DEF: INCOME CONCEPTS (UDB) \n", "5: ildef_se | on | DEF: INCOME CONCEPTS (non-standardized) \n", "6: random_se | on | DEF: Random assignment \n", "7: TransLMA_se | off | DEF: Modelling labour market transitions (DO NOT S ... \n", "8: tudef_se | on | DEF: ASSESSMENT UNITS \n", "9: yem_se | off (with switch set for MWA) | DEF: minimum wage \n", "10: neg_se | on | DEF: recode negative self-employment income to zer ... \n", "11: yemcomp_se | on | BEN: wage compensation scheme COVID-19 (ONLY WORK ... \n", "12: bunct_se | off | BEN: unemployment benefit (contributory) \n", "13: bfapl_se | off (with switch set for PBE) | BEN: Parental leave benefit \n", "14: bpa_se | off (with switch set for PBE) | BEN: Special leave days other parent (10 days) \n", "15: tscee_se | on | SIC: Employee Social Insurance contribution \n", "16: tscer_se | on | SIC: Employer Social Insurance contribution \n", "17: tscse_se | on | SIC: Self-employed Social Insurance contribution \n", "18: tin_se | on | TAX: Personal Income tax \n", "19: tinkt_se | on | TAX: Tax on Capital Income \n", "20: bch_se | on | BEN: Child benefit \n", "21: bho_se | on | BEN: Housing allowance \n", "22: bhope_se | on | BEN: Housing allowance for pensioners \n", "23: bsamt_se | on | BEN: Social Assistance (means-tested) \n", "24: output_std_se | on | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "25: output_std_hh_se | off | DEF: STANDARD OUTPUT HOUSEHOLD LEVEL " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].systems[\"SE_2021\"].policies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here we see that some policies are turned **off** by default. Note that the behaviour of the policies can be controlled from the connector. We can for example switch the policy bunct_se to **on**. Let us first look at the policy:" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "PolicyInSystem\n", "------------------------------\n", "\t ID: 'bde78132-3f44-4d2e-a1ea-4849f88c277601f1c7ff-3b6d-4191-bc71-bb86db5603d6'\n", "\t comment: 'BEN: unemployment benefit (contributory)'\n", "\t extensions: 0 elements\n", "\t functions: 16 elements\n", "\t name: 'bunct_se'\n", "\t order: '13'\n", "\t polID: '01f1c7ff-3b6d-4191-bc71-bb86db5603d6'\n", "\t private: 'no'\n", "\t spineOrder: '13'\n", "\t switch: 'off'\n", "\t sysID: 'bde78132-3f44-4d2e-a1ea-4849f88c2776'" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].systems[\"SE_2021\"].policies[12]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We see here the attribute switch that is part of the PolicyInSystem class. This attribute, and similarly the other attributes of the object, is modifiable and the changes that you will make will be passed to the EUROMOD software when simulating. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{important} \n", "Currently, the python connector does not support the save option. Therefore, changes implemented during a Python session cannot be saved.\n", "\n", "To apply permanent changes to the model, we recommend using the User Interface of EUROMOD. \n", "```" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "```{attention}\n", "Note that the python connector is not checking what kind of modifications you make to the model. Changing values of attributes like ID's are definitely not recommended. \n", "```" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "editable": true, "slideshow": { "slide_type": "" }, "tags": [] }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Simulation for system SE_2021 with dataset SE_2021_b1 finished.\n" ] }, { "data": { "text/plain": [ "0.0" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].systems[\"SE_2021\"].policies[13].switch = 'on'\n", "out_with_bunct_se = mod.countries[\"SE\"].systems[\"SE_2021\"].run(data,\"SE_2021_b1\")\n", "# Here we see that the average benefit, which is represented by ils_ben, is indeed larger by switching on the bunct_se policy.\n", "out_baseline.outputs[0].ils_ben.mean() - out_with_bunct_se.outputs[0].ils_ben.mean()" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: setdefault_se | on | DEF: SET DEFAULT \n", "1: uprate_se | on | DEF: UPRATING FACTORS \n", "2: ConstDef_se | on | DEF: CONSTANTS \n", "3: IlsDef_se | on | DEF: INCOME CONCEPTS (standardized) \n", "4: IlsUDBdef_se | on | DEF: INCOME CONCEPTS (UDB) \n", "5: ildef_se | on | DEF: INCOME CONCEPTS (non-standardized) \n", "6: random_se | on | DEF: Random assignment \n", "7: TransLMA_se | off | DEF: Modelling labour market transitions (DO NOT S ... \n", "8: tudef_se | on | DEF: ASSESSMENT UNITS \n", "9: yem_se | off (with switch set for MWA) | DEF: minimum wage \n", "10: neg_se | on | DEF: recode negative self-employment income to zer ... \n", "11: yemcomp_se | on | BEN: wage compensation scheme COVID-19 (ONLY WORK ... \n", "12: bunct_se | off | BEN: unemployment benefit (contributory) \n", "13: bfapl_se | on (with switch set for PBE) | BEN: Parental leave benefit \n", "14: bpa_se | off (with switch set for PBE) | BEN: Special leave days other parent (10 days) \n", "15: tscee_se | on | SIC: Employee Social Insurance contribution \n", "16: tscer_se | on | SIC: Employer Social Insurance contribution \n", "17: tscse_se | on | SIC: Self-employed Social Insurance contribution \n", "18: tin_se | on | TAX: Personal Income tax \n", "19: tinkt_se | on | TAX: Tax on Capital Income \n", "20: bch_se | on | BEN: Child benefit \n", "21: bho_se | on | BEN: Housing allowance \n", "22: bhope_se | on | BEN: Housing allowance for pensioners \n", "23: bsamt_se | on | BEN: Social Assistance (means-tested) \n", "24: output_std_se | on | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "25: output_std_hh_se | off | DEF: STANDARD OUTPUT HOUSEHOLD LEVEL " ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].systems[\"SE_2021\"].policies" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As mentioned earlier, the connector mimicks the hierarchical structure of the UI. Hence, the definition of functions and parameters are defined on the country level, and their actual implementation are here also accessible via the Tax System. Note that also here, the values of a Parameter and the switch of a Function can be manipulated through the Python Connector without saving the changes permanently:" ] }, { "cell_type": "code", "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Overview of the functions defined in the bho_se policy:\n", "0: DefVar | Temporary variables for Housing Allowance for pens ... \n", "1: Elig | Living with partner \n", "2: ArithOp | Wealth to be included in the means \n", "3: Elig | Living without partner \n", "4: ArithOp | Wealth to be included in the means \n", "5: Allocate | Allocation of wealth to the partners \n", "6: Elig | Elderly or disabled adult (i.e. head or partner) \n", "7: BenCalc | \"Reserved amount (\"\"income disregard\"\")\" \n", "8: BenCalc | Change in definition of Income Means for for Housi ... \n", "9: DefIl | Income Means for Housing Allowance for pensioners \n", "10: BenCalc | Income of children is not take into account in the ... \n", "11: BenCalc | Maximum housing allowance \n", "12: BenCalc | \n", "13: BenCalc | Maximum housing allowance \n", "14: BenCalc | Maximum housing allowance \n", "15: Allocate | Allocation of income to the partners \n", "16: BenCalc | Final housing allowance for pensioners \n", "17: Allocate | Sharing housing cost \n", "18: BenCalc | Housing allowance for pensioners \n", "\n", "System specific Implementation of functions:\n", "0: DefVar | on | Temporary variables for Housing Allowance for pens ... \n", "1: Elig | on | Living with partner \n", "2: ArithOp | on | Wealth to be included in the means \n", "3: Elig | on | Living without partner \n", "4: ArithOp | on | Wealth to be included in the means \n", "5: Allocate | on | Allocation of wealth to the partners \n", "6: Elig | on | Elderly or disabled adult (i.e. head or partner) \n", "7: BenCalc | on | \"Reserved amount (\"\"income disregard\"\")\" \n", "8: BenCalc | on | Change in definition of Income Means for for Housi ... \n", "9: DefIl | on | Income Means for Housing Allowance for pensioners \n", "10: BenCalc | on | Income of children is not take into account in the ... \n", "11: BenCalc | on | Maximum housing allowance \n", "12: BenCalc | off | \n", "13: BenCalc | off | Maximum housing allowance \n", "14: BenCalc | on | Maximum housing allowance \n", "15: Allocate | on | Allocation of income to the partners \n", "16: BenCalc | on | Final housing allowance for pensioners \n", "17: Allocate | on | Sharing housing cost \n", "18: BenCalc | on | Housing allowance for pensioners \n", "\n" ] } ], "source": [ "print(\"Overview of the functions defined in the bho_se policy:\")\n", "print(mod.countries[\"SE\"].policies[22].functions)\n", "print(\"System specific Implementation of functions:\")\n", "print(mod.countries[\"SE\"].systems[\"SE_2021\"].policies[22].functions)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Overview of the parameters defined in the bho_se policy:\n", "0: i_means_bhope_prel\n", "\n", "Implementation of parameters:\n", "0: i_means_bhope_prel | 0 \n", "\n" ] } ], "source": [ "print(\"Overview of the parameters defined in the bho_se policy:\")\n", "print(mod.countries[\"SE\"].policies[22].functions[0].parameters)\n", "print(\"Implementation of parameters:\")\n", "print(mod.countries[\"SE\"].systems[\"SE_2021\"].policies[22].functions[0].parameters)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Other Important EUROMOD Objects\n", "Central to the EUROMOD project, next to the coding of the policies is the microdata. How datasets should be treated by the model is configured in the model already. The attributes of the datasets are just like the spine-elements accessible and modifiable." ] }, { "cell_type": "code", "execution_count": 17, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: SE_2007_a4 \n", "1: SE_2008_a3 \n", "2: training_data\n", "3: SE_2010_a1 \n", "4: SE_2012_a2 \n", "5: SE_2015_a1 \n", "6: SE_2009_hhot \n", "7: SE_2010_hhot \n", "8: SE_2011_hhot \n", "9: SE_2012_hhot \n", "10: SE_2013_hhot\n", "11: SE_2014_hhot\n", "12: SE_2015_hhot\n", "13: SE_2016_hhot\n", "14: SE_2017_hhot\n", "15: SE_2016_a1 \n", "16: SE_2018_hhot\n", "17: SE_2019_hhot\n", "18: SE_2018_a2 \n", "19: SE_2017_a3 \n", "20: SE_2020_hhot\n", "21: SE_2019_a1 \n", "22: SE_2020_b1 \n", "23: SE_2021_hhot\n", "24: SE_2022_hhot\n", "25: SE_2021_b1 \n", "26: SE_2023_hhot" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In the previous section we used SE_2021_b1. Let us have a look at it." ] }, { "cell_type": "code", "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Dataset\n", "------------------------------\n", "\t ID: 'c7b651ed-b311-4e39-80b4-18ca19957ce7'\n", "\t coicopVersion: ''\n", "\t comment: ''\n", "\t currency: 'national'\n", "\t decimalSign: '.'\n", "\t name: 'SE_2021_b1'\n", "\t private: 'no'\n", "\t readXVariables: 'no'\n", "\t useCommonDefault: 'no'\n", "\t yearCollection: '2021'\n", "\t yearInc: '2020'" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].datasets[\"SE_2021_b1\"]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Similarly to the attributes in the `Policy`, `Function` and `Parameter` objects, the attributes of the Dataset can be modified here. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can further check what datasets are implemented for a given system, for example SE_2021, as follows:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: training_data | \n", "1: SE_2019_a1 | \n", "2: SE_2020_b1 | \n", "3: SE_2021_hhot | \n", "4: SE_2021_b1 | best match " ] }, "execution_count": 25, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"][\"SE_2021\"].datasets" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Another important concept in euromod are extensions that are defined globally on the `Model` level:" ] }, { "cell_type": "code", "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: Benefit Take-up Adjustments \n", "1: Tax Compliance Adjustments \n", "2: Full Year Adjustments \n", "3: Uprating by Average Adjustment \n", "4: Extended Policy Simulation \n", "5: Parental leave benefits \n", "6: Minimum Wage Adjustments \n", "7: HHoT unemployment extension \n", "8: EUROMOD JRC-Interface \n", "9: HHoT - Extended Simulation \n", "10: HHoT - Non Compulsory Payments" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.extensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Or locally on the `Country` level:" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: COVID benefit \n", "1: Benefit Take-up Adjustments \n", "2: Tax Compliance Adjustments \n", "3: Full Year Adjustments \n", "4: Uprating by Average Adjustment \n", "5: Extended Policy Simulation \n", "6: Parental leave benefits \n", "7: Minimum Wage Adjustments \n", "8: HHoT unemployment extension \n", "9: EUROMOD JRC-Interface \n", "10: HHoT - Extended Simulation \n", "11: HHoT - Non Compulsory Payments" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].extensions" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `extensions` attribute is of type Container. If we want to access the information stored in the Minimum Wage Adjustments extension for example, we can simply use the following command: " ] }, { "cell_type": "code", "execution_count": 31, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Extension\n", "------------------------------\n", "\t ID: '557c232a-9ce6-4808-b52f-ca5e02fe8cf4'\n", "\t look: '|BUTTON_COLOR=-16744384|'\n", "\t name: 'Minimum Wage Adjustments'\n", "\t shortName: 'MWA'" ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"SE\"].extensions[7]" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 4 }