7  Architecture of the model

7.1 Design

The model is a static, arithmetical microsimulation of the Polish personal tax and social-contribution system and of cash family benefits, in the tradition of EUROMOD (Sutherland and Figari 2013): every person’s liabilities and entitlements are computed from his or her own characteristics and those of the family and household, under the rules of a given year, with no behavioural response. Its distinctive feature is that all policy logic lives in YAML files: 11 modules with 234 rules, and one parameter registry per year with 172 parameters. A small Python engine interprets them. A policy expert can read and change the rules without reading Python.

A module is an ordered list of rules; every amount, rate, threshold and age the rules use is a named parameter of the registry (base_parameters_<year>.yml). Each rule creates or overwrites one person-level variable:

- variable_name: podstawa_zus_praca
  calculate: |
    podstawa_zus_praca = przychody_z_pracy

- variable_name: liczba_dzieci_familii
  groupby: {by: famid, column: czy_dziecko_fam, agg: sum}

Three rule kinds exist:

  • calculate — a block of assignments; the value of the last assignment becomes the rule’s variable (intermediate names are local);
  • expression — a single expression;
  • groupby — a group transform (sum, max, min, cumsum, …) by family, household or any other column, broadcast back to persons. This is how family and household aggregation (joint filing, family income tests, household disposable income) is expressed.

A rule may carry several of these keys; they are executed in the order in which they appear in the YAML mapping (e.g. podstawa_wspolna first sums the spouses’ bases by family and then applies a calculate to the sum).

7.2 Evaluation semantics

The expression language is a whitelisted subset of Python evaluated on pandas columns by an abstract-syntax-tree interpreter: arithmetic and comparison operators, and/or/not (element-wise), and the functions iif (vectorised if-then-else), min/max (element-wise), round, floor, ceil, abs, sqrt, exp, log, weighted median/percentile and a few aggregation helpers. Name resolution order is: local names of the block → data columns → parameters. No loops, attribute access or imports are possible, so a module cannot execute arbitrary code.

Four semantic rules matter when reading results:

  1. Input columns win. A rule whose variable already exists in the input data is skipped (with a warning) unless it carries always_compute: true. This lets stylised data pin a variable (e.g. business age), but it also means that a stale input column silently replaces a formula; only dochod_dzialalnosc is protected by always_compute.
  2. One parameter registry per year. The engine reads the registry of the selected year, then applies scenario overrides. Modules may not declare parameters (the engine rejects them). In the first edition module parameters overrode the year file, so 2025 and 2026 ran on 2024 benefit amounts. The 2025 and 2026 registries are generated by the indexation engine from published values and indexation policies (Section 6.6).
  3. Order is data flow. Modules run in a fixed order (Figure 7.1); a variable must be produced by an earlier rule or module. Rules may overwrite variables created earlier in the same run (used once, to make a non-earning spouse a joint-filing taxpayer).
  4. Determinism. No random numbers are drawn during simulation; every random attribute is drawn in the data (Part I). Two runs on the same input give identical results, and a reform’s effect is not confounded by re-randomisation.

7.3 Module sequence and data flow

Figure 7.1: Data flow between modules: number of variables produced by the row module and used by the column module. Modules execute left to right.

The flow follows the logic of a pay slip and a tax return: social contributions first (they are deductible from the PIT base and reduce the health-contribution base), health contributions next (their deductibility depends on the PIT form), local taxes and KRUS, then the three PIT forms — linear and ryczałt before the scale because the joint-filing rules and the child-credit income test need the linear income of spouses — then family benefits, which need the income after taxes for their income tests, and finally household aggregates.

Table 7.1: Module inventory (2024 rules).
Module Rules Registry parameters used Group rules Legal basis
Unemployment benefit 4 13 0 Act on employment promotion (2004), art. 71–73; Act on the labour market (2025)
ZUS 18 30 0 Act on the social insurance system (1998); Entrepreneurs Law art. 18 (start relief)
ZUS sickness/maternity 5 12 1 Act on cash benefits from sickness and maternity insurance (1999)
NFZ 8 11 0 Act on publicly financed health care (2004), art. 79–81
Local taxes/KRUS 8 16 0 Act on local taxes and fees (1991); Act on farmers’ social insurance (1990)
PIT linear 13 9 2 PIT act art. 30c (19% linear tax)
PIT ryczałt 32 12 0 Act on lump-sum income tax (1998), art. 12
PIT scale 67 21 14 PIT act art. 6, 21 (PIT-0), 22, 26, 27, 27f
Family benefits 55 39 14 Act on family benefits (2003); Act on state aid in raising children (2016)
Social assistance 14 14 3 Act on social assistance (2004), art. 8, 37, 38
Aggregates 10 5 3 — (definitions: OECD-modified scale, 60% median poverty line)

7.4 Parameter hygiene

In the first edition the same statutory amount was defined several times (the PIT-0 limit four times under two names, with two values), and about 80 statutory values were literals inside rules, out of reach of scenarios and indexation. Both were fixed in the second round of corrections:

  • One definition per amount. The registry holds each parameter once; the PIT-0 limit (85,528 PLN), the youth age and the senior ages are shared by the scale, linear and ryczałt modules.
  • No statutory literals in rules. The KRUS contributions and area bands, the ryczałt health multipliers, the family-benefit age bands, the age of majority, the OECD scale and the poverty line are named parameters. The 19 numbers left in rule bodies are structural (ryczałt rate codes, the code of the senior PIT-0 relief, child ordinals of the credit, the 12-month window of the contribution ladder, a sentinel and the decile grid). A test (tests/test_registry.py) fails if a module declares parameters, a rule contains a new literal, a parameter lacks an indexation policy or a year registry is incomplete.

7.5 Units, weights and outputs

All amounts are annual. Contributions and taxes are computed per person; joint filing, the child tax credit and family-benefit income tests group persons by family (famid); disposable income and its equivalised value are household totals assigned to each member. Weighted national totals are \(\sum_i w_i x_i\times 1000\) with person weights \(w_i\) in thousands.

The pipeline adds about 190 variables. The ones used in Part III are listed in Appendix B; the most important are the contribution totals (skladki_zus_lacznie, obciazenia_zus, skladka_nfz_lacznie), the three PIT liabilities (pit_skala_ostateczny, podatek_nalezny_36l, ryczalt_nalezny), total family benefits (laczne_swiadczenia_rodzinne) and disposable income (dochod_dysp, dochod_dysp_gd, dochod_ekwiwalentny).

7.6 Scenarios, years and reproducibility

A scenario is a YAML file of parameter overrides keyed by module, e.g. raising the tax-reducing amount in the scale module. The scenario runner executes the same pipeline on stylised households and on the microdata and caches results under a fingerprint — a hash of the scenario file, every module, the base-parameter file, the input data and the engine package — so a result can never be read after any of its inputs changed. Years are selected by the parameter registry; complete 2025 and 2026 registries exist (Section 6.6). The whole chain (data, scenarios, pytest, the hypothetical-household suite and, weekly, the reports and this documentation) runs in continuous integration (scripts/ci.sh) with pinned dependencies.

7.7 How the modules are verified in this part

Each module chapter shows the module’s behaviour on stylised households (single persons, couples, families with children, the three self-employment forms, civil-contract workers and pensioners) whose earnings vary on a 600 PLN grid from 0 to 360,000 PLN per year, run through the production pipeline. Two independent checks are reported:

  • an oracle: an independent re-implementation of the main 2024 formulas written from the statute (not from the YAML), compared with the pipeline on the grid (Table 8.3 in Section 8.4);
  • the project’s own regression suite of 192 hand-computed checks on 21 hypothetical households (Section 14.1).

Disagreements are investigated with targeted test households and collected in Chapter 14.