{ "cells": [ { "cell_type": "markdown", "id": "d8526d43", "metadata": {}, "source": [ "# User Guide\n", "\n", "This guide is a thorough tour of the Euromod Connector. It assumes you have\n", "already installed the package and can load a model (if not, start with\n", "[Getting Started](getstarted.ipynb)). Where Getting Started shows *the happy\n", "path*, this guide explains *the object model* and the full set of options for\n", "running simulations and building counterfactual reforms.\n", "\n", "**Contents**\n", "\n", "1. [Setup and reproducible paths](#setup)\n", "2. [The `Model` object](#model)\n", "3. [Navigating the model: countries, the object hierarchy](#navigate)\n", "4. [The spine: policies, functions, parameters](#spine)\n", "5. [Systems and datasets](#systems)\n", "6. [Running a simulation](#running)\n", "7. [Building reforms I — policy switches](#switches)\n", "8. [Building reforms II — overwriting constants](#constants)\n", "9. [Add-ons](#addons)\n", "10. [Extensions](#extensions)\n", "11. [Requesting specific outputs](#requested)\n", "12. [Run options reference](#options)\n", "13. [Working across countries](#multicountry)\n", "14. [Caveats](#caveats)" ] }, { "cell_type": "markdown", "id": "e7e40880", "metadata": {}, "source": [ "(setup)=\n", "## 1. Setup and reproducible paths\n", "\n", "A simulation needs a **model** (policy rules) and **input microdata**. Throughout\n", "this guide we use the **training datasets** that ship with every public EUROMOD\n", "release, so nothing here depends on confidential data.\n", "\n", "Edit the two paths below to point at your own EUROMOD installation. `MODEL_PATH`\n", "is the model/release folder; `DATA_DIR` is where the input microdata lives (the\n", "model's `Input` folder in a standard release)." ] }, { "cell_type": "code", "execution_count": 1, "id": "65972bf7", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:50.880577Z", "iopub.status.busy": "2026-07-10T10:37:50.880577Z", "iopub.status.idle": "2026-07-10T10:37:54.371927Z", "shell.execute_reply": "2026-07-10T10:37:54.368421Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using EUROMOD as defined in C:\\EUROMOD\\Executable\n" ] } ], "source": [ "import os\n", "import pandas as pd\n", "from euromod import Model\n", "\n", "# --- Point these to your local EUROMOD installation -------------------------\n", "# MODEL_PATH : a EUROMOD model/release folder (the one that contains 'XMLParam').\n", "# DATA_DIR : folder with the input microdata (.txt). In a public release this\n", "# is the model's own 'Input' folder, which ships with the freely\n", "# distributable *training* datasets used throughout these docs.\n", "MODEL_PATH = r\"C:\\EUROMOD\\EUROMOD_RELEASE\"\n", "DATA_DIR = os.path.join(MODEL_PATH, \"Input\")\n", "\n", "# keep DataFrame previews compact in the rendered docs\n", "pd.set_option(\"display.max_rows\", 8, \"display.max_columns\", 8)" ] }, { "cell_type": "markdown", "id": "9509b592", "metadata": {}, "source": [ "(model)=\n", "## 2. The `Model` object\n", "\n", "`Model` is the entry point. Pass it the path to a EUROMOD model folder (the one\n", "containing `XMLParam`). Loading is lazy where it can be, so creating the object\n", "is cheap." ] }, { "cell_type": "code", "execution_count": 3, "id": "20a798be", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:54.454466Z", "iopub.status.busy": "2026-07-10T10:37:54.446333Z", "iopub.status.idle": "2026-07-10T10:37:54.624439Z", "shell.execute_reply": "2026-07-10T10:37:54.624439Z" } }, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Model\n", "------------------------------\n", "\t countries: 28 elements\n", "\t extensions: 17 elements\n", "\t model_path: 'C:\\\\EUROMOD\\\\EUROMOD_RELEASE'" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod = Model(MODEL_PATH)\n", "mod" ] }, { "cell_type": "markdown", "id": "cda5ebfd", "metadata": {}, "source": [ "Every connector object has an **informative representation**: printing it shows\n", "its user-relevant attributes and how many elements each container holds. The\n", "`Model` has two you will use constantly:\n", "\n", "- `countries` — a container of `Country` objects;\n", "- `extensions` — the model-wide extensions (more on these\n", " [below](#extensions))." ] }, { "cell_type": "code", "execution_count": 4, "id": "ffc09281", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:54.632638Z", "iopub.status.busy": "2026-07-10T10:37:54.632638Z", "iopub.status.idle": "2026-07-10T10:37:54.697529Z", "shell.execute_reply": "2026-07-10T10:37:54.697529Z" } }, "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 \n", "11: Benefit Calibration Adjustments \n", "12: Consumption Inflation Adjustment \n", "13: HHoT - Monthly Unemployment extension\n", "14: HFCS data \n", "15: HHoT - childcare costs \n", "16: HHoT - sickness benefits " ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.extensions" ] }, { "cell_type": "markdown", "id": "b849d3a3", "metadata": {}, "source": [ "(navigate)=\n", "## 3. Navigating the model\n", "\n", "The connector mirrors the hierarchy of the EUROMOD user interface as a tree of\n", "Python objects. Containers can be indexed **by position** or **by name**, and\n", "they slice like lists." ] }, { "cell_type": "code", "execution_count": 5, "id": "bb562f65", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:54.705520Z", "iopub.status.busy": "2026-07-10T10:37:54.705520Z", "iopub.status.idle": "2026-07-10T10:37:54.772975Z", "shell.execute_reply": "2026-07-10T10:37:54.772975Z" } }, "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": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries # a Container of Country objects" ] }, { "cell_type": "code", "execution_count": 6, "id": "bae8e727", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:54.780968Z", "iopub.status.busy": "2026-07-10T10:37:54.772975Z", "iopub.status.idle": "2026-07-10T10:37:59.572732Z", "shell.execute_reply": "2026-07-10T10:37:59.572732Z" } }, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Country\n", "------------------------------\n", "\t ct_factors: 434 elements\n", "\t datasets: 42 elements\n", "\t extensions: 17 elements\n", "\t local_extensions: 0 elements\n", "\t name: 'IT'\n", "\t policies: 57 elements\n", "\t systems: 21 elements\n", "\t upratefactors: 46 elements" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.countries[\"IT\"] # index by two-letter country code" ] }, { "cell_type": "markdown", "id": "ddb20bb7", "metadata": {}, "source": [ "A `Country` groups everything defined for that country: its `datasets`,\n", "`policies`, `systems`, and any country-local `extensions`. As with the model,\n", "printing shows the shape of each." ] }, { "cell_type": "code", "execution_count": 7, "id": "101907f7", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:59.572732Z", "iopub.status.busy": "2026-07-10T10:37:59.572732Z", "iopub.status.idle": "2026-07-10T10:37:59.645855Z", "shell.execute_reply": "2026-07-10T10:37:59.645855Z" } }, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Country\n", "------------------------------\n", "\t ct_factors: 434 elements\n", "\t datasets: 42 elements\n", "\t extensions: 17 elements\n", "\t local_extensions: 0 elements\n", "\t name: 'IT'\n", "\t policies: 57 elements\n", "\t systems: 21 elements\n", "\t upratefactors: 46 elements" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "it = mod.countries[\"IT\"]\n", "it" ] }, { "cell_type": "markdown", "id": "c32f86fe", "metadata": {}, "source": [ "(spine)=\n", "## 4. The spine: policies, functions, parameters\n", "\n", "The **spine** is EUROMOD's ordered sequence of tax-benefit calculations. It has\n", "three nested levels:\n", "\n", "```\n", "Policy (e.g. income tax)\n", " └─ Function (e.g. a benefit calculation, an eligibility test)\n", " └─ Parameter (e.g. a rate, a threshold, a formula)\n", "```\n", "\n", "These are **defined** at the `Country` level (the design of the rules) and\n", "**implemented** at the `System` level (the design *as parameterised for a given\n", "policy year*). That distinction matters: the same policy has different parameter\n", "values in `IT_2019` and `IT_2020`.\n", "\n", "Let's look at the policies defined for Italy." ] }, { "cell_type": "code", "execution_count": 8, "id": "ff3e6a65", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:37:59.645855Z", "iopub.status.busy": "2026-07-10T10:37:59.645855Z", "iopub.status.idle": "2026-07-10T10:38:00.314751Z", "shell.execute_reply": "2026-07-10T10:38:00.314751Z" } }, "outputs": [ { "data": { "text/plain": [ "0: SetDefault_it | | DEF: DEFAULT VALUES \n", "1: Uprate_it | | DEF: UPRATING FACTORS \n", "2: uprate_bands_it | (with switch set for UAA) | DEF: Uprating in bands \n", "3: ConstDef_it | | DEF: CONSTANTS AND INITIALISATION OF VARIABLES \n", "4: random_it | | DEF: assign random numbers \n", "5: ILsDef_it | | DEF: STANDARD INCOME CONCEPTS \n", "6: ILsUDBDef_it | | DEF: UDB related STANDARD INCOME LISTS \n", "7: ILDef_it | | DEF: INCOME CONCEPTS \n", "8: TransLMA_it | | DEF: Modelling labour market transitions (DO NOT S ... \n", "9: TUDef_it | | DEF: ASSESSMENT UNITS \n", "10: TCA_it | (with switch set for TCA) | SWITCH: Tax Compliance Adjustments \n", "11: yem_it | (with switch set for MWA) | DEF: minimum wage \n", "12: neg_it | | DEF: recode negative self-employment income to zer ... \n", "13: sickcomp_it | (with switch set for HHoT_hl) | BEN: sickness compensation (this policy changes ye ... \n", "14: bmact_it | (with switch set for PBE) | BEN: Mandatory Maternity Leave Allowance (Indennit ... \n", "15: bpact_it | (with switch set for PBE) | BEN: Paternity Leave Allowance (Congedo papà) \n", "16: bplct_it | (with switch set for PBE) | BEN: Parental Leave (Indennità per astensione fac ... \n", "17: bmanc_it | (with switch set for PBE) | BEN: State Maternity Benefit (Assegno di Materni ... \n", "18: hhot_switch_it | (with switch set for HHoT_un, WEB) | DEF: switch on bun for HHoT extension \n", "19: bunct01_it | | BEN: Wage Supplementation scheme - PART SIMULATED \n", "20: bunct02_it | | BEN: Unemployment benefit (Indennita' di disoccupa ... \n", "21: sicee_it | | SIC: Employee Social Insurance Contributions (Cont ... \n", "22: sicer_it | | SIC: Employer Social Insurance Contributions (Cont ... \n", "23: sicse_it | | SIC: Self-employed Social Insurance Contributions ... \n", "24: tinrt_it | | TAX: Tax on rental income \n", "25: tpr_it | | TAX: Property Tax (IMU) \n", "26: poaxp_it | | BEN: Pension extra payment \n", "27: tinto_it | | TAX: Additional solidarity contributions \n", "28: tinyse_it | | TAX: Income Tax Self-employed (flat tax optional r ... \n", "29: tintsna_it | | TAX: Personal Income Tax: deduction and schedule ( ... \n", "30: tintc_it | | TAX: Personal Income Tax: personal tax credits (IR ... \n", "31: tinna_it | | TAX: Personal Income Tax: Family tax credits (IRPE ... \n", "32: tintciw_it | | TAX: In work refundable Tax Credit (from 2014) \n", "33: tinrg_it | | TAX: Additional Regional Personal Income Tax (Addi ... \n", "34: tinkt_it | | TAX: Tax on capital incomes (Tassazione dei reddit ... \n", "35: poamt_it | | BEN: Social Allowance for elderly \n", "36: bfacc_it | | BEN: Mother bonus \n", "37: bfacpxc_it | | BEN: Family Allowance for couple and 0 child (Asse ... \n", "38: bfalp_it | | BEN: Family Allowance for 1 parent and children (A ... \n", "39: bfacpwc_it | | BEN: Family Allowance for 2 parents and children ( ... \n", "40: isee_it | | DEF: Indicator of Economic Situation \n", "41: bfaba_it | | BEN: New born bonus \n", "42: bfach_it | (with switch set for HHoT_cc) | BEN: Childcare bonus \n", "43: bmamt_it | (with switch set for PBE) | BEN: Municipalities Maternity Benefit (Assegno di ... \n", "44: bsamm_it | | BEN: Income Support (ReI - Reddito di Inclusione) \n", "45: bau_it | | BEN: Children allowance (Assegno Unico) \n", "46: bls_COVID_it | | BEN: COVD Lump sum benefits \n", "47: bls_ENERGY_it | | BEN: ENERGY related Lump sum benefits \n", "48: bsals_it | | BEN: Lumps sum pro-poor benefit (Carta Dedicata a ... \n", "49: REm_it | | BEN: Emergency income (REm) \n", "50: bfaHFCS_it | (with switch set for HFCS) | BEN: Family Allowance with HFCS data \n", "51: tco_it | | TAX: Commodities \n", "52: spp_it | | BEN: Special Price Policies (OFF by default - swit ... \n", "53: xcc_it | (with switch set for HHoT_cc) | COST: Childcare \n", "54: output_std_it | | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "55: parben_output_std_it | (with switch set for PBE, WEB) | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "56: output_std_hh_it | | DEF: STANDARD OUTPUT HOUSEHOLD LEVEL " ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "it.policies" ] }, { "cell_type": "markdown", "id": "a7d55c43", "metadata": {}, "source": [ "Drill into a single policy to see its functions, and into a function to see its\n", "parameters. Here we inspect the personal income tax policy `tinrt_it`.\n", "\n", "> **Indexing note.** Country and system containers can be indexed by name\n", "> (`mod.countries[\"IT\"]`), but `policies` and `functions` are keyed by their\n", "> internal ID, so we pick one out by its readable name with a simple\n", "> comprehension." ] }, { "cell_type": "code", "execution_count": 9, "id": "9804e2e8", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:00.314751Z", "iopub.status.busy": "2026-07-10T10:38:00.314751Z", "iopub.status.idle": "2026-07-10T10:38:06.032799Z", "shell.execute_reply": "2026-07-10T10:38:06.032799Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "0: DefConst | \n", "1: ArithOp | \n", "2: ArithOp | Proportion of rental income which is taxable \n", "3: ArithOp | \n", "4: ArithOp | Tax on rental income \n", "5: ArithOp | Tax on rental income \n", "\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "0: $tinrt_IncomeTaxable | taxable rental income \n", "1: $tinrt_FixedRate | Rental income is subject to a fixed rate: 21% \n", "2: $tinrt_FixedRate1 | Rental income is subject to a fixed rate: 10% \n", "3: [Placeholder] | \n", "4: [Placeholder] | \n", "5: [Placeholder] | \n", "\n" ] } ], "source": [ "tax = [p for p in it.policies if p.name == \"tinrt_it\"][0]\n", "print(tax.functions)\n", "print(tax.functions[0].parameters)" ] }, { "cell_type": "markdown", "id": "99d6d490", "metadata": {}, "source": [ "The **system-level** view adds the state that applies for a given year — most\n", "importantly the `switch` (whether a policy/function is active) and the concrete\n", "parameter `value`s. Compare the country-level definition above with the\n", "`IT_2020` implementation below: the system view shows each policy's on/off\n", "switch." ] }, { "cell_type": "code", "execution_count": 10, "id": "5a431779", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:06.041019Z", "iopub.status.busy": "2026-07-10T10:38:06.032799Z", "iopub.status.idle": "2026-07-10T10:38:06.273486Z", "shell.execute_reply": "2026-07-10T10:38:06.273486Z" } }, "outputs": [ { "data": { "text/plain": [ "0: SetDefault_it | on | DEF: DEFAULT VALUES \n", "1: Uprate_it | on | DEF: UPRATING FACTORS \n", "2: uprate_bands_it | on (with switch set for UAA) | DEF: Uprating in bands \n", "3: ConstDef_it | on | DEF: CONSTANTS AND INITIALISATION OF VARIABLES \n", "4: random_it | on | DEF: assign random numbers \n", "5: ILsDef_it | on | DEF: STANDARD INCOME CONCEPTS \n", "6: ILsUDBDef_it | on | DEF: UDB related STANDARD INCOME LISTS \n", "7: ILDef_it | on | DEF: INCOME CONCEPTS \n", "8: TransLMA_it | off | DEF: Modelling labour market transitions (DO NOT S ... \n", "9: TUDef_it | on | DEF: ASSESSMENT UNITS \n", "10: TCA_it | off (with switch set for TCA) | SWITCH: Tax Compliance Adjustments \n", "11: yem_it | off (with switch set for MWA) | DEF: minimum wage \n", "12: neg_it | on | DEF: recode negative self-employment income to zer ... \n", "13: sickcomp_it | off (with switch set for HHoT_hl) | BEN: sickness compensation (this policy changes ye ... \n", "14: bmact_it | off (with switch set for PBE) | BEN: Mandatory Maternity Leave Allowance (Indennit ... \n", "15: bpact_it | off (with switch set for PBE) | BEN: Paternity Leave Allowance (Congedo papà) \n", "16: bplct_it | off (with switch set for PBE) | BEN: Parental Leave (Indennità per astensione fac ... \n", "17: bmanc_it | off (with switch set for PBE) | BEN: State Maternity Benefit (Assegno di Materni ... \n", "18: hhot_switch_it | on (with switch set for HHoT_un, WEB) | DEF: switch on bun for HHoT extension \n", "19: bunct01_it | off | BEN: Wage Supplementation scheme - PART SIMULATED \n", "20: bunct02_it | off | BEN: Unemployment benefit (Indennita' di disoccupa ... \n", "21: sicee_it | on | SIC: Employee Social Insurance Contributions (Cont ... \n", "22: sicer_it | on | SIC: Employer Social Insurance Contributions (Cont ... \n", "23: sicse_it | on | SIC: Self-employed Social Insurance Contributions ... \n", "24: tinrt_it | on | TAX: Tax on rental income \n", "25: tpr_it | on | TAX: Property Tax (IMU) \n", "26: poaxp_it | on | BEN: Pension extra payment \n", "27: tinto_it | on | TAX: Additional solidarity contributions \n", "28: tinyse_it | on | TAX: Income Tax Self-employed (flat tax optional r ... \n", "29: tintsna_it | on | TAX: Personal Income Tax: deduction and schedule ( ... \n", "30: tintc_it | on | TAX: Personal Income Tax: personal tax credits (IR ... \n", "31: tinna_it | on | TAX: Personal Income Tax: Family tax credits (IRPE ... \n", "32: tintciw_it | on | TAX: In work refundable Tax Credit (from 2014) \n", "33: tinrg_it | on | TAX: Additional Regional Personal Income Tax (Addi ... \n", "34: tinkt_it | on | TAX: Tax on capital incomes (Tassazione dei reddit ... \n", "35: poamt_it | on | BEN: Social Allowance for elderly \n", "36: bfacc_it | on | BEN: Mother bonus \n", "37: bfacpxc_it | on | BEN: Family Allowance for couple and 0 child (Asse ... \n", "38: bfalp_it | on | BEN: Family Allowance for 1 parent and children (A ... \n", "39: bfacpwc_it | on | BEN: Family Allowance for 2 parents and children ( ... \n", "40: isee_it | on | DEF: Indicator of Economic Situation \n", "41: bfaba_it | on | BEN: New born bonus \n", "42: bfach_it | on (with switch set for HHoT_cc) | BEN: Childcare bonus \n", "43: bmamt_it | off (with switch set for PBE) | BEN: Municipalities Maternity Benefit (Assegno di ... \n", "44: bsamm_it | on | BEN: Income Support (ReI - Reddito di Inclusione) \n", "45: bau_it | off | BEN: Children allowance (Assegno Unico) \n", "46: bls_COVID_it | off | BEN: COVD Lump sum benefits \n", "47: bls_ENERGY_it | n/a | BEN: ENERGY related Lump sum benefits \n", "48: bsals_it | n/a | BEN: Lumps sum pro-poor benefit (Carta Dedicata a ... \n", "49: REm_it | on | BEN: Emergency income (REm) \n", "50: bfaHFCS_it | on (with switch set for HFCS) | BEN: Family Allowance with HFCS data \n", "51: tco_it | off | TAX: Commodities \n", "52: spp_it | off | BEN: Special Price Policies (OFF by default - swit ... \n", "53: xcc_it | off (with switch set for HHoT_cc) | COST: Childcare \n", "54: output_std_it | on | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "55: parben_output_std_it | off (with switch set for PBE, WEB) | DEF: STANDARD OUTPUT INDIVIDUAL LEVEL \n", "56: output_std_hh_it | off | DEF: STANDARD OUTPUT HOUSEHOLD LEVEL " ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "it.systems[\"IT_2020\"].policies" ] }, { "cell_type": "markdown", "id": "f769b2cb", "metadata": {}, "source": [ "(systems)=\n", "## 5. Systems and datasets\n", "\n", "A `System` is a country's tax-benefit rules for one policy year. To run one you\n", "must pair it with a **dataset**. A system lists the datasets configured for it,\n", "and marks the **best match** — the dataset the model authors recommend for that\n", "system." ] }, { "cell_type": "code", "execution_count": 11, "id": "df283c86", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:06.281501Z", "iopub.status.busy": "2026-07-10T10:38:06.281501Z", "iopub.status.idle": "2026-07-10T10:38:06.793409Z", "shell.execute_reply": "2026-07-10T10:38:06.793409Z" } }, "outputs": [ { "data": { "text/plain": [ "0: training_data | \n", "1: IT_2018_a0 | \n", "2: IT_2018_a3 | \n", "3: IT_2019_a0 | \n", "4: IT_2019_a1 | \n", "5: IT_2020_hhot | \n", "6: IT_2010_a6_2010_03_e1 | \n", "7: IT_2021_b1 | best match \n", "8: IT_training_data | \n", "9: IT_2021_h1_imp1 | " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "it.systems[\"IT_2020\"].datasets" ] }, { "cell_type": "markdown", "id": "262a60d7", "metadata": {}, "source": [ "The `dataset_id` you pass to `run()` selects which dataset-specific\n", "configuration (uprating factors, default values, currency) EUROMOD applies. It\n", "must be one of the datasets configured for the system. Here we use the training\n", "dataset `IT_training_data`." ] }, { "cell_type": "markdown", "id": "dd6f98a8", "metadata": {}, "source": [ "(running)=\n", "## 6. Running a simulation\n", "\n", "`run()` takes the input microdata as a `pandas.DataFrame` plus the `dataset_id`,\n", "and returns a `Simulation`. String variables are ignored (EUROMOD works on\n", "numeric variables), and the input must contain the `idhh` and `idperson`\n", "identifiers." ] }, { "cell_type": "code", "execution_count": 12, "id": "724332bf", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:06.801213Z", "iopub.status.busy": "2026-07-10T10:38:06.801213Z", "iopub.status.idle": "2026-07-10T10:38:14.715797Z", "shell.execute_reply": "2026-07-10T10:38:14.715797Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Simulation for system IT_2020 with dataset IT_training_data finished.\n" ] }, { "data": { "text/plain": [ "------------------------------\n", "Simulation\n", "------------------------------\n", "\t constantsToOverwrite: {}\n", "\t errors: []\n", "\t output_filenames: ['it_2020_std.txt']\n", "\t outputs: Pandas DataFrame of 579 variables and 7482 observations." ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data = pd.read_csv(os.path.join(DATA_DIR, \"IT_training_data.txt\"), sep=\"\\t\")\n", "baseline = it.systems[\"IT_2020\"].run(data, \"IT_training_data\")\n", "baseline" ] }, { "cell_type": "markdown", "id": "94a595c8", "metadata": {}, "source": [ "The `Simulation` object bundles:\n", "\n", "- `outputs` — a container of result DataFrames (most systems produce one; some\n", " produce several, e.g. when an add-on adds its own output);\n", "- `output_filenames` — the name of each output;\n", "- `errors` — any errors and warnings raised by the engine;\n", "- `constantsToOverwrite` — a record of the constants you changed (see below).\n", "\n", "Access the main output by position or by filename:" ] }, { "cell_type": "code", "execution_count": 13, "id": "4dfd332d", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:14.715797Z", "iopub.status.busy": "2026-07-10T10:38:14.715797Z", "iopub.status.idle": "2026-07-10T10:38:14.805528Z", "shell.execute_reply": "2026-07-10T10:38:14.805528Z" } }, "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", "
idhhidpersonidmotheridfather...tu_it_it_IsPartnertu_it_it_IsOwnDependentChildtu_it_it_IsDepParenttu_fa_family_it_HeadID
01.0101.00.00.0...0.00.00.0101.0
12.0201.00.00.0...0.00.00.0201.0
23.0301.00.00.0...0.00.00.0301.0
34.0401.00.00.0...0.00.00.0401.0
45.0501.00.00.0...0.00.00.0501.0
\n", "

5 rows × 579 columns

\n", "
" ], "text/plain": [ " idhh idperson idmother idfather ... tu_it_it_IsPartner \\\n", "0 1.0 101.0 0.0 0.0 ... 0.0 \n", "1 2.0 201.0 0.0 0.0 ... 0.0 \n", "2 3.0 301.0 0.0 0.0 ... 0.0 \n", "3 4.0 401.0 0.0 0.0 ... 0.0 \n", "4 5.0 501.0 0.0 0.0 ... 0.0 \n", "\n", " tu_it_it_IsOwnDependentChild tu_it_it_IsDepParent tu_fa_family_it_HeadID \n", "0 0.0 0.0 101.0 \n", "1 0.0 0.0 201.0 \n", "2 0.0 0.0 301.0 \n", "3 0.0 0.0 401.0 \n", "4 0.0 0.0 501.0 \n", "\n", "[5 rows x 579 columns]" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "baseline.outputs[0].head()" ] }, { "cell_type": "markdown", "id": "b045e74d", "metadata": {}, "source": [ "By default `run()` prints a completion message and any warnings. Pass\n", "`verbose=False` to silence that (useful in loops), and check `sim.errors`\n", "yourself. If the simulation aborts, `run()` raises an exception." ] }, { "cell_type": "markdown", "id": "e67593a7", "metadata": {}, "source": [ "(switches)=\n", "## 7. Building reforms I — policy switches\n", "\n", "The real power of the connector is running **counterfactuals**. The simplest\n", "reform switches a policy on or off. Each `PolicyInSystem` has a `switch`\n", "attribute (`'on'`/`'off'`) you can set before running. Changes live only for the\n", "current Python session — they are **not** written back to the model files.\n", "\n", "Below we turn a benefit policy off and measure the effect on mean household\n", "disposable income (`ils_dispy`)." ] }, { "cell_type": "code", "execution_count": 14, "id": "c9ca90ce", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:14.805528Z", "iopub.status.busy": "2026-07-10T10:38:14.805528Z", "iopub.status.idle": "2026-07-10T10:38:20.269819Z", "shell.execute_reply": "2026-07-10T10:38:20.269819Z" } }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "baseline mean disposable income: 1,084.51\n", "reform mean disposable income: 1,084.22\n", "difference: -0.29\n" ] } ], "source": [ "# baseline mean disposable income\n", "base_dispy = baseline.outputs[0].ils_dispy.mean()\n", "\n", "# switch a policy off and re-run\n", "bfacc = [p for p in it.systems[\"IT_2020\"].policies if p.name == \"bfacc_it\"][0]\n", "bfacc.switch = \"off\"\n", "reform = it.systems[\"IT_2020\"].run(data, \"IT_training_data\", verbose=False)\n", "reform_dispy = reform.outputs[0].ils_dispy.mean()\n", "\n", "# restore the switch so later cells start from the baseline again\n", "bfacc.switch = \"on\"\n", "\n", "print(f\"baseline mean disposable income: {base_dispy:,.2f}\")\n", "print(f\"reform mean disposable income: {reform_dispy:,.2f}\")\n", "print(f\"difference: {reform_dispy - base_dispy:,.2f}\")" ] }, { "cell_type": "markdown", "id": "ca482326", "metadata": {}, "source": [ "The same pattern works at the `Function` level (each function-in-system also has\n", "a `switch`). This is the recommended way to toggle components, because it is\n", "explicit and easy to reset." ] }, { "cell_type": "markdown", "id": "1999fbad", "metadata": {}, "source": [ "(constants)=\n", "## 8. Building reforms II — overwriting constants\n", "\n", "Many EUROMOD parameters are expressed in terms of named **constants** (e.g.\n", "uprating indices, thresholds). Rather than editing the model, you can override\n", "constants for a single run with the `constantsToOverwrite` argument.\n", "\n", "It is a `dict` keyed by a `(constant_name, group)` tuple, where `group` is the\n", "constant's group number as a string (or `\"\"` when it has none), mapping to the\n", "new value as a string." ] }, { "cell_type": "code", "execution_count": 15, "id": "0cbd766c", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:20.277907Z", "iopub.status.busy": "2026-07-10T10:38:20.277907Z", "iopub.status.idle": "2026-07-10T10:38:25.014427Z", "shell.execute_reply": "2026-07-10T10:38:25.014427Z" } }, "outputs": [ { "data": { "text/plain": [ "{('$penIndexA_2007', ''): '1.05'}" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sim_const = it.systems[\"IT_2020\"].run(\n", " data, \"IT_training_data\",\n", " constantsToOverwrite={(\"$penIndexA_2007\", \"\"): \"1.05\"},\n", " verbose=False,\n", ")\n", "sim_const.constantsToOverwrite" ] }, { "cell_type": "markdown", "id": "43bbeb8f", "metadata": {}, "source": [ "`sim.constantsToOverwrite` echoes back exactly what was overridden, so a\n", "`Simulation` is self-documenting about the reform it represents." ] }, { "cell_type": "markdown", "id": "cb1c70d2", "metadata": {}, "source": [ "(addons)=\n", "## 9. Add-ons\n", "\n", "**Add-ons** are self-contained blocks of policy logic (e.g. marginal tax rate\n", "calculations, labour-market adjustments) that are woven into the spine at run\n", "time. Pass them via the `addons` argument.\n", "\n", "Each add-on is applied for one of its **add-on systems**. You can specify this\n", "two ways:\n", "\n", "- **Name only** — `addons=[\"MTR\"]`. EUROMOD resolves the applicable add-on\n", " system automatically, exactly as the user interface does, by matching the\n", " run's system against the add-on's applicability rules.\n", "- **Name and system explicitly** — `addons=[(\"MTR\", \"MTR\")]`, when you want to\n", " pin a specific add-on system.\n", "\n", "The name-only form is the convenient default; reach for the explicit tuple only\n", "when the automatic choice is ambiguous." ] }, { "cell_type": "code", "execution_count": 16, "id": "a2c3db41", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:25.014427Z", "iopub.status.busy": "2026-07-10T10:38:25.014427Z", "iopub.status.idle": "2026-07-10T10:38:31.908714Z", "shell.execute_reply": "2026-07-10T10:38:31.908714Z" } }, "outputs": [ { "data": { "text/plain": [ "['it_2020_base_mtr.txt', 'it_2020_mtr.txt']" ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# name-only: the add-on system is resolved automatically\n", "mtr = it.systems[\"IT_2020\"].run(data, \"IT_training_data\", addons=[\"MTR\"], verbose=False)\n", "mtr.output_filenames" ] }, { "cell_type": "markdown", "id": "4e6d4e9b", "metadata": {}, "source": [ "The MTR add-on emits its own output alongside the standard one. Here is the mean\n", "marginal tax rate from its dedicated output file:" ] }, { "cell_type": "code", "execution_count": 17, "id": "f45b60b2", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:31.908714Z", "iopub.status.busy": "2026-07-10T10:38:31.908714Z", "iopub.status.idle": "2026-07-10T10:38:31.977400Z", "shell.execute_reply": "2026-07-10T10:38:31.977400Z" } }, "outputs": [ { "data": { "text/plain": [ "20.76796201407752" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr.outputs[\"it_2020_mtr.txt\"].mtrpc.mean()" ] }, { "cell_type": "markdown", "id": "6f3129dc", "metadata": {}, "source": [ "The explicit form produces the same result; it just names the add-on system\n", "directly instead of relying on resolution:\n", "\n", "```python\n", "it.systems[\"IT_2020\"].run(data, \"IT_training_data\", addons=[(\"MTR\", \"MTR\")])\n", "```\n", "\n", "If the name-only form is **ambiguous** — i.e. more than one add-on system\n", "applies to the run — EUROMOD raises an error asking you to disambiguate. In that\n", "case, supply the system explicitly with the tuple form." ] }, { "cell_type": "markdown", "id": "aonav-md1", "metadata": {}, "source": [ "### Inspecting add-ons as objects\n", "\n", "Beyond passing them to `run()`, add-ons are also exposed as first-class\n", "objects on the model, so you can explore their structure the same way you\n", "navigate a country. `mod.addons` is a container of `Addon` objects." ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c1", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: CT_XBASE\n", "1: CT_XCES \n", "2: CT_XCIS \n", "3: CT_XCQ \n", "4: LMA \n", "5: MTR \n", "6: NRR \n", "7: TCA \n", "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.addons" ] }, { "cell_type": "markdown", "id": "aonav-md2", "metadata": {}, "source": [ "An `Addon` is navigable like a `Country`: it has `systems` (of type\n", "`AddonSystem`) and a `policies` spine (policies -> functions -> parameters).\n", "Unlike a country it has no datasets of its own, and it simply references the\n", "model-wide `extensions`." ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "------------------------------\n", "Addon\n", "------------------------------\n", "\t extensions: 17 elements\n", "\t name: 'MTR'\n", "\t policies: ao_control_MTR, MTR_PREP, MTR_INIT, MTR_STORE, MTR_CALC\n", "\t systems: 26 elements\n", "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ao = mod.addons[\"MTR\"]\n", "ao" ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c3", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: MTR \n", "1: MTR_PL \n", "2: MTR_EE \n", "3: MTR_SI \n", "4: MTR_SK \n", "5: MTR_NL \n", "6: MTR_RO \n", "7: MTR_FI \n", "8: MTR_BG \n", "9: MTR_DE \n", "10: MTR_LT\n", "11: MTR_AT\n", "12: MTR_PT\n", "13: MTR_EL\n", "14: MTR_BE\n", "15: MTR_FR\n", "16: MTR_IE\n", "17: MTR_IT\n", "18: MTR_LV\n", "19: MTR_MT\n", "20: MTR_HR\n", "21: MTR_CY\n", "22: MTR_DK\n", "23: MTR_ES\n", "24: MTR_CZ\n", "25: MTR_LU\n", "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ao.systems" ] }, { "cell_type": "markdown", "id": "aonav-md3", "metadata": {}, "source": [ "Each **add-on system** declares which base-country systems it applies to,\n", "using the same wildcard rules as the user interface.\n", "`get_applicable_systems()` returns the add-on systems that match a given base\n", "system - exactly the resolution that `run(addons=[\"MTR\"])` performs for you." ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c4", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: MTR_IT\n", "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "ao.get_applicable_systems(\"IT_2020\")" ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c5", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(['it_20*'], [])" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_it = ao.systems[\"MTR_IT\"]\n", "mtr_it.applies_to_patterns, mtr_it.not_applicable_patterns" ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c6", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "True" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_it.is_applicable(\"IT_2020\") # accepts a system name or a System object" ] }, { "cell_type": "markdown", "id": "aonav-md4", "metadata": {}, "source": [ "The add-on's own policies, functions and parameters are navigable too -\n", "handy for seeing exactly what an add-on injects into the spine:" ] }, { "cell_type": "code", "execution_count": null, "id": "aonav-c7", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0: DefVar | define new variables \n", "1: Elig | define eligible persons to calculate MTR \n", "2: ArithOp | calculate change in earnings \n", "3: ArithOp | calculate MTR (in percentage terms) \n", "4: ArithOp | calculate the contribution by components: public p ... \n", "5: ArithOp | calculate the contribution by components: means-te ... \n", "6: ArithOp | calculate the contribution by components: non mean ... \n", "7: ArithOp | calculate the contribution by components: taxes \n", "8: ArithOp | calculate the contribution by components: employee ... \n", "9: ArithOp | calculate the contribution by components: self-emp ... \n", "10: ArithOp | calculate the contribution by components: other SI ... \n", "11: Restore | RESTORE results of mtr_baseline tax-benefit calcul ... \n", "12: DefOutput | DEFINE output for marginal tax rate calculations \n", "" ] }, "execution_count": null, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mtr_calc = [p for p in ao.policies if p.name == \"MTR_CALC\"][0]\n", "mtr_calc.functions" ] }, { "cell_type": "markdown", "id": "aonav-md5", "metadata": {}, "source": [ "> **These objects are a read-only inspection view.** Navigating or editing\n", "> an `Addon` - its systems, policies or parameters - does **not** change what\n", "> a simulation does: at run time EUROMOD reads the add-on afresh from the\n", "> model files. To apply an add-on in a run use the `addons=` argument shown\n", "> above; to change an add-on's contents, edit it in the EUROMOD user\n", "> interface." ] }, { "cell_type": "markdown", "id": "f38cba90", "metadata": {}, "source": [ "(extensions)=\n", "## 10. Extensions\n", "\n", "**Extensions** are toggleable variants of the policy logic (e.g. a benefit\n", "take-up adjustment). Unlike add-ons, they are already part of the model; you\n", "switch them on or off per run with the `switches` argument — a list of\n", "`(extension_short_name, on/off)` tuples." ] }, { "cell_type": "code", "execution_count": 18, "id": "b075d597", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:31.977400Z", "iopub.status.busy": "2026-07-10T10:38:31.977400Z", "iopub.status.idle": "2026-07-10T10:38:32.043213Z", "shell.execute_reply": "2026-07-10T10:38:32.043213Z" } }, "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 \n", "11: Benefit Calibration Adjustments \n", "12: Consumption Inflation Adjustment \n", "13: HHoT - Monthly Unemployment extension\n", "14: HFCS data \n", "15: HHoT - childcare costs \n", "16: HHoT - sickness benefits " ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mod.extensions # available extension short names (model-wide)" ] }, { "cell_type": "code", "execution_count": 19, "id": "6dc175a0", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:32.043213Z", "iopub.status.busy": "2026-07-10T10:38:32.043213Z", "iopub.status.idle": "2026-07-10T10:38:37.076459Z", "shell.execute_reply": "2026-07-10T10:38:37.076459Z" } }, "outputs": [ { "data": { "text/plain": [ "-0.09019424396342401" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# switch on the Benefit Take-up Adjustment (BTA) extension\n", "bta = it.systems[\"IT_2020\"].run(\n", " data, \"IT_training_data\",\n", " switches=[(\"BTA\", True)],\n", " verbose=False,\n", ")\n", "bta.outputs[0].ils_ben.mean() - baseline.outputs[0].ils_ben.mean()" ] }, { "cell_type": "markdown", "id": "e5c34a65", "metadata": {}, "source": [ "A system also exposes its default extension state via\n", "`get_default_extensions(dataset)`, useful for inspecting what is on before you\n", "override anything." ] }, { "cell_type": "markdown", "id": "54767d71", "metadata": {}, "source": [ "(requested)=\n", "## 11. Requesting specific outputs\n", "\n", "By default EUROMOD returns the standard output defined by the model. If you only\n", "need a handful of variables or income lists, request them explicitly. This\n", "produces an additional compact `custom_output` dataset and is much cheaper to\n", "move around than the full output." ] }, { "cell_type": "code", "execution_count": 20, "id": "7798a729", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:37.084423Z", "iopub.status.busy": "2026-07-10T10:38:37.076459Z", "iopub.status.idle": "2026-07-10T10:38:42.504356Z", "shell.execute_reply": "2026-07-10T10:38:42.504356Z" } }, "outputs": [ { "data": { "text/plain": [ "[(7482, 579), (7482, 3)]" ] }, "execution_count": 20, "metadata": {}, "output_type": "execute_result" } ], "source": [ "sim_custom = it.systems[\"IT_2020\"].run(\n", " data, \"IT_training_data\",\n", " requested_vars=[\"ils_dispy\", \"ils_origy\"],\n", " verbose=False,\n", ")\n", "[df.shape for df in sim_custom.outputs]" ] }, { "cell_type": "markdown", "id": "f3394163", "metadata": {}, "source": [ "Related arguments let you request income lists (`requested_incomelists`),\n", "variable groups (`requested_vargroups`), and income-list groups\n", "(`requested_ilgroups`)." ] }, { "cell_type": "markdown", "id": "45b0fb6c", "metadata": {}, "source": [ "(options)=\n", "## 12. Run options reference\n", "\n", "A quick reference of the most useful `run()` arguments (see the API reference\n", "for the full signature):\n", "\n", "| Argument | Purpose |\n", "| --- | --- |\n", "| `data`, `dataset_id` | **Required.** Input microdata and the dataset config to apply. |\n", "| `constantsToOverwrite` | Override named constants for this run. |\n", "| `addons` | Add-ons to weave in — name-only or `(name, system)`. |\n", "| `switches` | Extensions to switch on/off — `(short_name, bool)`. |\n", "| `requested_vars` / `requested_incomelists` | Return a compact custom output. |\n", "| `euro` | Force monetary output in euro. |\n", "| `public_components_only` | Ignore private components of the model. |\n", "| `outputpath` | Also write the output to disk at this path. |\n", "| `verbose` | Print progress/warnings (default `True`). |" ] }, { "cell_type": "markdown", "id": "fc67860d", "metadata": {}, "source": [ "(multicountry)=\n", "## 13. Working across countries\n", "\n", "Because everything is plain Python objects, comparative work is just a loop.\n", "Here we compute mean disposable income under the latest system of several\n", "countries, each on its own training data." ] }, { "cell_type": "code", "execution_count": 21, "id": "94075465", "metadata": { "execution": { "iopub.execute_input": "2026-07-10T10:38:42.512488Z", "iopub.status.busy": "2026-07-10T10:38:42.512488Z", "iopub.status.idle": "2026-07-10T10:39:10.892193Z", "shell.execute_reply": "2026-07-10T10:39:10.892193Z" } }, "outputs": [ { "data": { "text/plain": [ "AT 1694.418332\n", "IT 1084.507587\n", "SL 1061.144695\n", "Name: mean_disposable_income, dtype: float64" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "results = {}\n", "for cc, sysname in [(\"AT\", \"AT_2025\"), (\"IT\", \"IT_2020\"), (\"SL\", \"SL_1996\")]:\n", " d = pd.read_csv(os.path.join(DATA_DIR, f\"{cc}_training_data.txt\"), sep=\"\\t\")\n", " sim = mod.countries[cc].systems[sysname].run(d, f\"{cc}_training_data\", verbose=False)\n", " results[cc] = sim.outputs[0].ils_dispy.mean()\n", "\n", "pd.Series(results, name=\"mean_disposable_income\")" ] }, { "cell_type": "markdown", "id": "e7d97ed9", "metadata": {}, "source": [ "(caveats)=\n", "## 14. Caveats\n", "\n", "- **Changes are session-only.** Setting a `switch`, a parameter `value`, or\n", " passing `constantsToOverwrite` affects only the current run(s); nothing is\n", " written back to the model files. For permanent changes use the EUROMOD user\n", " interface.\n", "- **The connector does not validate model edits.** Changing structural\n", " attributes (e.g. object `ID`s) can produce meaningless results — don't.\n", "- **Numeric input only.** String variables in your DataFrame are not passed to\n", " the engine; the data must contain `idhh` and `idperson`.\n", "- **Reset what you change.** When toggling switches inside a loop or notebook,\n", " restore them afterwards (as we did above) so later cells start from a known\n", " baseline." ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "pygments_lexer": "ipython3" } }, "nbformat": 4, "nbformat_minor": 5 }