euromod-linking 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- euromod_linking-0.1.0/CHANGELOG.md +34 -0
- euromod_linking-0.1.0/LICENSE.txt +291 -0
- euromod_linking-0.1.0/MANIFEST.in +14 -0
- euromod_linking-0.1.0/PKG-INFO +170 -0
- euromod_linking-0.1.0/README.md +133 -0
- euromod_linking-0.1.0/pyproject.toml +75 -0
- euromod_linking-0.1.0/setup.cfg +4 -0
- euromod_linking-0.1.0/src/euromod_linking/__init__.py +56 -0
- euromod_linking-0.1.0/src/euromod_linking/compat.py +435 -0
- euromod_linking-0.1.0/src/euromod_linking/dimensions.py +264 -0
- euromod_linking-0.1.0/src/euromod_linking/env.py +70 -0
- euromod_linking-0.1.0/src/euromod_linking/ingest.py +229 -0
- euromod_linking-0.1.0/src/euromod_linking/mappings/regional_projections.yaml +58 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/__init__.py +11 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/base.py +62 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/cells.py +167 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/__init__.py +375 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/hierarchy.py +293 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/imputation.py +142 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/scoring.py +206 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/states.py +82 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/targets.py +376 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/lma_labour_alignment/weights.py +189 -0
- euromod_linking-0.1.0/src/euromod_linking/methods/scale_variables.py +378 -0
- euromod_linking-0.1.0/src/euromod_linking/query.py +482 -0
- euromod_linking-0.1.0/src/euromod_linking/registry.py +139 -0
- euromod_linking-0.1.0/src/euromod_linking/resources.py +34 -0
- euromod_linking-0.1.0/src/euromod_linking/runner.py +167 -0
- euromod_linking-0.1.0/src/euromod_linking/scenarios.py +480 -0
- euromod_linking-0.1.0/src/euromod_linking/schemas/mapping.v1.schema.json +94 -0
- euromod_linking-0.1.0/src/euromod_linking/schemas/scenario.v1.schema.json +52 -0
- euromod_linking-0.1.0/src/euromod_linking/schemas/shock_table.v1.schema.json +29 -0
- euromod_linking-0.1.0/src/euromod_linking/session.py +103 -0
- euromod_linking-0.1.0/src/euromod_linking/shock_table.py +120 -0
- euromod_linking-0.1.0/src/euromod_linking.egg-info/PKG-INFO +170 -0
- euromod_linking-0.1.0/src/euromod_linking.egg-info/SOURCES.txt +48 -0
- euromod_linking-0.1.0/src/euromod_linking.egg-info/dependency_links.txt +1 -0
- euromod_linking-0.1.0/src/euromod_linking.egg-info/requires.txt +17 -0
- euromod_linking-0.1.0/src/euromod_linking.egg-info/top_level.txt +1 -0
- euromod_linking-0.1.0/tests/conftest.py +110 -0
- euromod_linking-0.1.0/tests/test_baseline_reporting.py +191 -0
- euromod_linking-0.1.0/tests/test_compat.py +398 -0
- euromod_linking-0.1.0/tests/test_dimensions.py +162 -0
- euromod_linking-0.1.0/tests/test_hierarchy_and_method.py +363 -0
- euromod_linking-0.1.0/tests/test_ingest_mapping.py +74 -0
- euromod_linking-0.1.0/tests/test_rate_metrics.py +174 -0
- euromod_linking-0.1.0/tests/test_scale_variables.py +388 -0
- euromod_linking-0.1.0/tests/test_scoring_cache.py +146 -0
- euromod_linking-0.1.0/tests/test_shock_table.py +92 -0
- euromod_linking-0.1.0/tests/test_weights.py +130 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
<!--next-version-placeholder-->
|
|
4
|
+
|
|
5
|
+
## v0.1.0 (25/08/2026)
|
|
6
|
+
|
|
7
|
+
First release.
|
|
8
|
+
|
|
9
|
+
Turns an external economic model's projected changes into transformed EUROMOD input
|
|
10
|
+
microdata and run parameters, so macro results can be evaluated at household level.
|
|
11
|
+
|
|
12
|
+
- **The shock table.** One canonical eight-column format every external model's output is
|
|
13
|
+
normalised into, identified by a content hash so the same economic scenario always has the
|
|
14
|
+
same id. Channels: `align`, `scale`, `constant` (`reweight` and `inject` are reserved).
|
|
15
|
+
- **Population cells** written over real EUROMOD input variables, never invented category
|
|
16
|
+
labels. `region` is NUTS-aware: coarser codes cover their subregions, and finer codes
|
|
17
|
+
collapse to the level the dataset supports.
|
|
18
|
+
- **Two entry points.** `apply_scenario` transforms input and executes nothing;
|
|
19
|
+
`run_scenario` additionally runs baseline and counterfactual. `validate_only=True` reports
|
|
20
|
+
what a scenario would do before paying for two simulations.
|
|
21
|
+
- **Two linking methods**, resolved from the shock channels rather than chosen by the caller:
|
|
22
|
+
`lma_labour_alignment` (two-level hierarchical alignment to employment and unemployment
|
|
23
|
+
targets, driving the LMA add-on) and `scale_variables` (cell-level arithmetic on input
|
|
24
|
+
variables and extension-aware income lists).
|
|
25
|
+
- **Model compatibility checking.** `check_compatibility` and `compatibility_matrix` verify a
|
|
26
|
+
method's required add-ons and extension switches against the model before a run, so a
|
|
27
|
+
missing `LMA_trans` fails during validation rather than after two simulations.
|
|
28
|
+
- **Declarative ingest.** External model output is read through mapping specs — YAML or a
|
|
29
|
+
dict — rather than bespoke parsing code.
|
|
30
|
+
|
|
31
|
+
Requires Python 3.11+ and a local EUROMOD model, which is distributed by the JRC at
|
|
32
|
+
<https://euromod-web.jrc.ec.europa.eu/download-euromod>. This targets the EUROMOD model for
|
|
33
|
+
the 27 EU member states; models built on the same engine but with different conventions
|
|
34
|
+
(SOUTHMOD, SWISSMOD, national models outside the EU) are out of scope.
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
# License
|
|
2
|
+
|
|
3
|
+
EUROPEAN UNION PUBLIC LICENCE v. 1.2
|
|
4
|
+
EUPL © the European Union 2007, 2016
|
|
5
|
+
|
|
6
|
+
This European Union Public Licence (the ‘EUPL’) applies to the Work (as defined
|
|
7
|
+
below) which is provided under the terms of this Licence. Any use of the Work,
|
|
8
|
+
other than as authorised under this Licence is prohibited (to the extent such
|
|
9
|
+
use is covered by a right of the copyright holder of the Work).
|
|
10
|
+
|
|
11
|
+
The Work is provided under the terms of this Licence when the Licensor (as
|
|
12
|
+
defined below) has placed the following notice immediately following the
|
|
13
|
+
copyright notice for the Work:
|
|
14
|
+
|
|
15
|
+
Licensed under the EUPL
|
|
16
|
+
|
|
17
|
+
or has expressed by any other means his willingness to license under the EUPL.
|
|
18
|
+
|
|
19
|
+
1. Definitions
|
|
20
|
+
|
|
21
|
+
In this Licence, the following terms have the following meaning:
|
|
22
|
+
|
|
23
|
+
- ‘The Licence’: this Licence.
|
|
24
|
+
|
|
25
|
+
- ‘The Original Work’: the work or software distributed or communicated by the
|
|
26
|
+
Licensor under this Licence, available as Source Code and also as Executable
|
|
27
|
+
Code as the case may be.
|
|
28
|
+
|
|
29
|
+
- ‘Derivative Works’: the works or software that could be created by the
|
|
30
|
+
Licensee, based upon the Original Work or modifications thereof. This Licence
|
|
31
|
+
does not define the extent of modification or dependence on the Original Work
|
|
32
|
+
required in order to classify a work as a Derivative Work; this extent is
|
|
33
|
+
determined by copyright law applicable in the country mentioned in Article 15.
|
|
34
|
+
|
|
35
|
+
- ‘The Work’: the Original Work or its Derivative Works.
|
|
36
|
+
|
|
37
|
+
- ‘The Source Code’: the human-readable form of the Work which is the most
|
|
38
|
+
convenient for people to study and modify.
|
|
39
|
+
|
|
40
|
+
- ‘The Executable Code’: any code which has generally been compiled and which is
|
|
41
|
+
meant to be interpreted by a computer as a program.
|
|
42
|
+
|
|
43
|
+
- ‘The Licensor’: the natural or legal person that distributes or communicates
|
|
44
|
+
the Work under the Licence.
|
|
45
|
+
|
|
46
|
+
- ‘Contributor(s)’: any natural or legal person who modifies the Work under the
|
|
47
|
+
Licence, or otherwise contributes to the creation of a Derivative Work.
|
|
48
|
+
|
|
49
|
+
- ‘The Licensee’ or ‘You’: any natural or legal person who makes any usage of
|
|
50
|
+
the Work under the terms of the Licence.
|
|
51
|
+
|
|
52
|
+
- ‘Distribution’ or ‘Communication’: any act of selling, giving, lending,
|
|
53
|
+
renting, distributing, communicating, transmitting, or otherwise making
|
|
54
|
+
available, online or offline, copies of the Work or providing access to its
|
|
55
|
+
essential functionalities at the disposal of any other natural or legal
|
|
56
|
+
person.
|
|
57
|
+
|
|
58
|
+
2. Scope of the rights granted by the Licence
|
|
59
|
+
|
|
60
|
+
The Licensor hereby grants You a worldwide, royalty-free, non-exclusive,
|
|
61
|
+
sublicensable licence to do the following, for the duration of copyright vested
|
|
62
|
+
in the Original Work:
|
|
63
|
+
|
|
64
|
+
- use the Work in any circumstance and for all usage,
|
|
65
|
+
- reproduce the Work,
|
|
66
|
+
- modify the Work, and make Derivative Works based upon the Work,
|
|
67
|
+
- communicate to the public, including the right to make available or display
|
|
68
|
+
the Work or copies thereof to the public and perform publicly, as the case may
|
|
69
|
+
be, the Work,
|
|
70
|
+
- distribute the Work or copies thereof,
|
|
71
|
+
- lend and rent the Work or copies thereof,
|
|
72
|
+
- sublicense rights in the Work or copies thereof.
|
|
73
|
+
|
|
74
|
+
Those rights can be exercised on any media, supports and formats, whether now
|
|
75
|
+
known or later invented, as far as the applicable law permits so.
|
|
76
|
+
|
|
77
|
+
In the countries where moral rights apply, the Licensor waives his right to
|
|
78
|
+
exercise his moral right to the extent allowed by law in order to make effective
|
|
79
|
+
the licence of the economic rights here above listed.
|
|
80
|
+
|
|
81
|
+
The Licensor grants to the Licensee royalty-free, non-exclusive usage rights to
|
|
82
|
+
any patents held by the Licensor, to the extent necessary to make use of the
|
|
83
|
+
rights granted on the Work under this Licence.
|
|
84
|
+
|
|
85
|
+
3. Communication of the Source Code
|
|
86
|
+
|
|
87
|
+
The Licensor may provide the Work either in its Source Code form, or as
|
|
88
|
+
Executable Code. If the Work is provided as Executable Code, the Licensor
|
|
89
|
+
provides in addition a machine-readable copy of the Source Code of the Work
|
|
90
|
+
along with each copy of the Work that the Licensor distributes or indicates, in
|
|
91
|
+
a notice following the copyright notice attached to the Work, a repository where
|
|
92
|
+
the Source Code is easily and freely accessible for as long as the Licensor
|
|
93
|
+
continues to distribute or communicate the Work.
|
|
94
|
+
|
|
95
|
+
4. Limitations on copyright
|
|
96
|
+
|
|
97
|
+
Nothing in this Licence is intended to deprive the Licensee of the benefits from
|
|
98
|
+
any exception or limitation to the exclusive rights of the rights owners in the
|
|
99
|
+
Work, of the exhaustion of those rights or of other applicable limitations
|
|
100
|
+
thereto.
|
|
101
|
+
|
|
102
|
+
5. Obligations of the Licensee
|
|
103
|
+
|
|
104
|
+
The grant of the rights mentioned above is subject to some restrictions and
|
|
105
|
+
obligations imposed on the Licensee. Those obligations are the following:
|
|
106
|
+
|
|
107
|
+
Attribution right: The Licensee shall keep intact all copyright, patent or
|
|
108
|
+
trademarks notices and all notices that refer to the Licence and to the
|
|
109
|
+
disclaimer of warranties. The Licensee must include a copy of such notices and a
|
|
110
|
+
copy of the Licence with every copy of the Work he/she distributes or
|
|
111
|
+
communicates. The Licensee must cause any Derivative Work to carry prominent
|
|
112
|
+
notices stating that the Work has been modified and the date of modification.
|
|
113
|
+
|
|
114
|
+
Copyleft clause: If the Licensee distributes or communicates copies of the
|
|
115
|
+
Original Works or Derivative Works, this Distribution or Communication will be
|
|
116
|
+
done under the terms of this Licence or of a later version of this Licence
|
|
117
|
+
unless the Original Work is expressly distributed only under this version of the
|
|
118
|
+
Licence — for example by communicating ‘EUPL v. 1.2 only’. The Licensee
|
|
119
|
+
(becoming Licensor) cannot offer or impose any additional terms or conditions on
|
|
120
|
+
the Work or Derivative Work that alter or restrict the terms of the Licence.
|
|
121
|
+
|
|
122
|
+
Compatibility clause: If the Licensee Distributes or Communicates Derivative
|
|
123
|
+
Works or copies thereof based upon both the Work and another work licensed under
|
|
124
|
+
a Compatible Licence, this Distribution or Communication can be done under the
|
|
125
|
+
terms of this Compatible Licence. For the sake of this clause, ‘Compatible
|
|
126
|
+
Licence’ refers to the licences listed in the appendix attached to this Licence.
|
|
127
|
+
Should the Licensee's obligations under the Compatible Licence conflict with
|
|
128
|
+
his/her obligations under this Licence, the obligations of the Compatible
|
|
129
|
+
Licence shall prevail.
|
|
130
|
+
|
|
131
|
+
Provision of Source Code: When distributing or communicating copies of the Work,
|
|
132
|
+
the Licensee will provide a machine-readable copy of the Source Code or indicate
|
|
133
|
+
a repository where this Source will be easily and freely available for as long
|
|
134
|
+
as the Licensee continues to distribute or communicate the Work.
|
|
135
|
+
|
|
136
|
+
Legal Protection: This Licence does not grant permission to use the trade names,
|
|
137
|
+
trademarks, service marks, or names of the Licensor, except as required for
|
|
138
|
+
reasonable and customary use in describing the origin of the Work and
|
|
139
|
+
reproducing the content of the copyright notice.
|
|
140
|
+
|
|
141
|
+
6. Chain of Authorship
|
|
142
|
+
|
|
143
|
+
The original Licensor warrants that the copyright in the Original Work granted
|
|
144
|
+
hereunder is owned by him/her or licensed to him/her and that he/she has the
|
|
145
|
+
power and authority to grant the Licence.
|
|
146
|
+
|
|
147
|
+
Each Contributor warrants that the copyright in the modifications he/she brings
|
|
148
|
+
to the Work are owned by him/her or licensed to him/her and that he/she has the
|
|
149
|
+
power and authority to grant the Licence.
|
|
150
|
+
|
|
151
|
+
Each time You accept the Licence, the original Licensor and subsequent
|
|
152
|
+
Contributors grant You a licence to their contributions to the Work, under the
|
|
153
|
+
terms of this Licence.
|
|
154
|
+
|
|
155
|
+
7. Disclaimer of Warranty
|
|
156
|
+
|
|
157
|
+
The Work is a work in progress, which is continuously improved by numerous
|
|
158
|
+
Contributors. It is not a finished work and may therefore contain defects or
|
|
159
|
+
‘bugs’ inherent to this type of development.
|
|
160
|
+
|
|
161
|
+
For the above reason, the Work is provided under the Licence on an ‘as is’ basis
|
|
162
|
+
and without warranties of any kind concerning the Work, including without
|
|
163
|
+
limitation merchantability, fitness for a particular purpose, absence of defects
|
|
164
|
+
or errors, accuracy, non-infringement of intellectual property rights other than
|
|
165
|
+
copyright as stated in Article 6 of this Licence.
|
|
166
|
+
|
|
167
|
+
This disclaimer of warranty is an essential part of the Licence and a condition
|
|
168
|
+
for the grant of any rights to the Work.
|
|
169
|
+
|
|
170
|
+
8. Disclaimer of Liability
|
|
171
|
+
|
|
172
|
+
Except in the cases of wilful misconduct or damages directly caused to natural
|
|
173
|
+
persons, the Licensor will in no event be liable for any direct or indirect,
|
|
174
|
+
material or moral, damages of any kind, arising out of the Licence or of the use
|
|
175
|
+
of the Work, including without limitation, damages for loss of goodwill, work
|
|
176
|
+
stoppage, computer failure or malfunction, loss of data or any commercial
|
|
177
|
+
damage, even if the Licensor has been advised of the possibility of such damage.
|
|
178
|
+
However, the Licensor will be liable under statutory product liability laws as
|
|
179
|
+
far such laws apply to the Work.
|
|
180
|
+
|
|
181
|
+
9. Additional agreements
|
|
182
|
+
|
|
183
|
+
While distributing the Work, You may choose to conclude an additional agreement,
|
|
184
|
+
defining obligations or services consistent with this Licence. However, if
|
|
185
|
+
accepting obligations, You may act only on your own behalf and on your sole
|
|
186
|
+
responsibility, not on behalf of the original Licensor or any other Contributor,
|
|
187
|
+
and only if You agree to indemnify, defend, and hold each Contributor harmless
|
|
188
|
+
for any liability incurred by, or claims asserted against such Contributor by
|
|
189
|
+
the fact You have accepted any warranty or additional liability.
|
|
190
|
+
|
|
191
|
+
10. Acceptance of the Licence
|
|
192
|
+
|
|
193
|
+
The provisions of this Licence can be accepted by clicking on an icon ‘I agree’
|
|
194
|
+
placed under the bottom of a window displaying the text of this Licence or by
|
|
195
|
+
affirming consent in any other similar way, in accordance with the rules of
|
|
196
|
+
applicable law. Clicking on that icon indicates your clear and irrevocable
|
|
197
|
+
acceptance of this Licence and all of its terms and conditions.
|
|
198
|
+
|
|
199
|
+
Similarly, you irrevocably accept this Licence and all of its terms and
|
|
200
|
+
conditions by exercising any rights granted to You by Article 2 of this Licence,
|
|
201
|
+
such as the use of the Work, the creation by You of a Derivative Work or the
|
|
202
|
+
Distribution or Communication by You of the Work or copies thereof.
|
|
203
|
+
|
|
204
|
+
11. Information to the public
|
|
205
|
+
|
|
206
|
+
In case of any Distribution or Communication of the Work by means of electronic
|
|
207
|
+
communication by You (for example, by offering to download the Work from a
|
|
208
|
+
remote location) the distribution channel or media (for example, a website) must
|
|
209
|
+
at least provide to the public the information requested by the applicable law
|
|
210
|
+
regarding the Licensor, the Licence and the way it may be accessible, concluded,
|
|
211
|
+
stored and reproduced by the Licensee.
|
|
212
|
+
|
|
213
|
+
12. Termination of the Licence
|
|
214
|
+
|
|
215
|
+
The Licence and the rights granted hereunder will terminate automatically upon
|
|
216
|
+
any breach by the Licensee of the terms of the Licence.
|
|
217
|
+
|
|
218
|
+
Such a termination will not terminate the licences of any person who has
|
|
219
|
+
received the Work from the Licensee under the Licence, provided such persons
|
|
220
|
+
remain in full compliance with the Licence.
|
|
221
|
+
|
|
222
|
+
13. Miscellaneous
|
|
223
|
+
|
|
224
|
+
Without prejudice of Article 9 above, the Licence represents the complete
|
|
225
|
+
agreement between the Parties as to the Work.
|
|
226
|
+
|
|
227
|
+
If any provision of the Licence is invalid or unenforceable under applicable
|
|
228
|
+
law, this will not affect the validity or enforceability of the Licence as a
|
|
229
|
+
whole. Such provision will be construed or reformed so as necessary to make it
|
|
230
|
+
valid and enforceable.
|
|
231
|
+
|
|
232
|
+
The European Commission may publish other linguistic versions or new versions of
|
|
233
|
+
this Licence or updated versions of the Appendix, so far this is required and
|
|
234
|
+
reasonable, without reducing the scope of the rights granted by the Licence. New
|
|
235
|
+
versions of the Licence will be published with a unique version number.
|
|
236
|
+
|
|
237
|
+
All linguistic versions of this Licence, approved by the European Commission,
|
|
238
|
+
have identical value. Parties can take advantage of the linguistic version of
|
|
239
|
+
their choice.
|
|
240
|
+
|
|
241
|
+
14. Jurisdiction
|
|
242
|
+
|
|
243
|
+
Without prejudice to specific agreement between parties,
|
|
244
|
+
|
|
245
|
+
- any litigation resulting from the interpretation of this License, arising
|
|
246
|
+
between the European Union institutions, bodies, offices or agencies, as a
|
|
247
|
+
Licensor, and any Licensee, will be subject to the jurisdiction of the Court
|
|
248
|
+
of Justice of the European Union, as laid down in article 272 of the Treaty on
|
|
249
|
+
the Functioning of the European Union,
|
|
250
|
+
|
|
251
|
+
- any litigation arising between other parties and resulting from the
|
|
252
|
+
interpretation of this License, will be subject to the exclusive jurisdiction
|
|
253
|
+
of the competent court where the Licensor resides or conducts its primary
|
|
254
|
+
business.
|
|
255
|
+
|
|
256
|
+
15. Applicable Law
|
|
257
|
+
|
|
258
|
+
Without prejudice to specific agreement between parties,
|
|
259
|
+
|
|
260
|
+
- this Licence shall be governed by the law of the European Union Member State
|
|
261
|
+
where the Licensor has his seat, resides or has his registered office,
|
|
262
|
+
|
|
263
|
+
- this licence shall be governed by Belgian law if the Licensor has no seat,
|
|
264
|
+
residence or registered office inside a European Union Member State.
|
|
265
|
+
|
|
266
|
+
Appendix
|
|
267
|
+
|
|
268
|
+
‘Compatible Licences’ according to Article 5 EUPL are:
|
|
269
|
+
|
|
270
|
+
- GNU General Public License (GPL) v. 2, v. 3
|
|
271
|
+
- GNU Affero General Public License (AGPL) v. 3
|
|
272
|
+
- Open Software License (OSL) v. 2.1, v. 3.0
|
|
273
|
+
- Eclipse Public License (EPL) v. 1.0
|
|
274
|
+
- CeCILL v. 2.0, v. 2.1
|
|
275
|
+
- Mozilla Public Licence (MPL) v. 2
|
|
276
|
+
- GNU Lesser General Public Licence (LGPL) v. 2.1, v. 3
|
|
277
|
+
- Creative Commons Attribution-ShareAlike v. 3.0 Unported (CC BY-SA 3.0) for
|
|
278
|
+
works other than software
|
|
279
|
+
- European Union Public Licence (EUPL) v. 1.1, v. 1.2
|
|
280
|
+
- Québec Free and Open-Source Licence — Reciprocity (LiLiQ-R) or Strong
|
|
281
|
+
Reciprocity (LiLiQ-R+).
|
|
282
|
+
|
|
283
|
+
The European Commission may update this Appendix to later versions of the above
|
|
284
|
+
licences without producing a new version of the EUPL, as long as they provide
|
|
285
|
+
the rights granted in Article 2 of this Licence and protect the covered Source
|
|
286
|
+
Code from exclusive appropriation.
|
|
287
|
+
|
|
288
|
+
All other changes or additions to this Appendix require the production of a new
|
|
289
|
+
EUPL version.
|
|
290
|
+
|
|
291
|
+
https://joinup.ec.europa.eu/collection/eupl/eupl-text-eupl-12
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# The wheel gets schemas/ and mappings/ from [tool.setuptools.package-data]; the
|
|
2
|
+
# sdist needs them named here too, along with the tests, so a source release can
|
|
3
|
+
# be checked out and run.
|
|
4
|
+
include LICENSE.txt
|
|
5
|
+
include README.md
|
|
6
|
+
include CHANGELOG.md
|
|
7
|
+
recursive-include src/euromod_linking/schemas *.json
|
|
8
|
+
recursive-include src/euromod_linking/mappings *.yaml
|
|
9
|
+
recursive-include tests *.py
|
|
10
|
+
|
|
11
|
+
# No `prune docs` / `prune build`: this file is an allowlist, and the sdist's
|
|
12
|
+
# default set never reaches outside src/, so both pruned nothing while warning
|
|
13
|
+
# on every build. Warnings nobody can act on are how real ones get ignored.
|
|
14
|
+
global-exclude __pycache__ *.py[cod] .DS_Store
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: euromod-linking
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Link external economic models to EUROMOD by transforming input microdata and run parameters
|
|
5
|
+
Author-email: Hannes Serruys <hannes.serruys@ec.europa.eu>
|
|
6
|
+
License-Expression: EUPL-1.2
|
|
7
|
+
Project-URL: Documentation, https://ec-jrc.github.io/JRC-EUROMOD-software-source-code/python-linking/
|
|
8
|
+
Project-URL: Source, https://github.com/ec-jrc/JRC-EUROMOD-software-source-code/tree/master/connectors/PythonLinking
|
|
9
|
+
Project-URL: EUROMOD model, https://euromod-web.jrc.ec.europa.eu/download-euromod
|
|
10
|
+
Keywords: EUROMOD,microsimulation,macro-micro linking,tax-benefit,microdata
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Operating System :: OS Independent
|
|
18
|
+
Requires-Python: >=3.11
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENSE.txt
|
|
21
|
+
Requires-Dist: euromod>=0.3.1
|
|
22
|
+
Requires-Dist: pandas>=2.0
|
|
23
|
+
Requires-Dist: numpy
|
|
24
|
+
Requires-Dist: jsonschema>=4.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: statsmodels>=0.14
|
|
27
|
+
Requires-Dist: scikit-learn>=1.4
|
|
28
|
+
Requires-Dist: scipy>=1.11
|
|
29
|
+
Provides-Extra: excel
|
|
30
|
+
Requires-Dist: openpyxl>=3.1; extra == "excel"
|
|
31
|
+
Requires-Dist: xlrd>=2.0.1; extra == "excel"
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8; extra == "dev"
|
|
34
|
+
Requires-Dist: openpyxl>=3.1; extra == "dev"
|
|
35
|
+
Requires-Dist: xlrd>=2.0.1; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# euromod-linking
|
|
39
|
+
|
|
40
|
+
Connect external economic models to [EUROMOD](https://euromod-web.jrc.ec.europa.eu/) by
|
|
41
|
+
transforming its input microdata and run parameters.
|
|
42
|
+
|
|
43
|
+
A macro model — a CGE model, a forecasting model, a policy scenario written by hand — projects
|
|
44
|
+
*changes*: employment by region and education, nominal wages, price levels. EUROMOD simulates
|
|
45
|
+
taxes and benefits on a household survey. This package is the layer between them: it takes those
|
|
46
|
+
projected changes as data, rewrites the microdata and run parameters so the survey population
|
|
47
|
+
matches them, and runs baseline and counterfactual simulations that differ *only* by the shock.
|
|
48
|
+
|
|
49
|
+
It is a standalone library. It has no dependency on any agent, notebook or UI, and is usable
|
|
50
|
+
directly from a script.
|
|
51
|
+
|
|
52
|
+
## Scope
|
|
53
|
+
|
|
54
|
+
**This library targets the JRC's EUROMOD model for the 27 EU member states, and only that
|
|
55
|
+
model.** It is not a general library for the EUROMOD *software*: models built on the same
|
|
56
|
+
engine — SOUTHMOD, SWISSMOD, and national or regional models outside the EU — will not work
|
|
57
|
+
with it.
|
|
58
|
+
|
|
59
|
+
It assumes EUROMOD's own EU-27 conventions throughout: the `ils_udb_*` User Database income
|
|
60
|
+
lists, the `les`/`les2` labour-status codings, `drgn1`/`drgn2` read as NUTS regions, variable
|
|
61
|
+
names such as `dwt`, `dag`, `deh`, `yem` and `yivwg`, the `$lhw` constant, and the
|
|
62
|
+
JRC-maintained LMA add-on. Those conventions are precisely what a different model changes.
|
|
63
|
+
|
|
64
|
+
## Install
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install euromod-linking # or: pip install -e .
|
|
68
|
+
pip install euromod-linking[excel] # to ingest .xlsx/.xlsm/.xls model output
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Requires Python 3.11+ and a local EUROMOD model and installation (see the `euromod` connector).
|
|
72
|
+
The model is distributed by the JRC and can be requested at
|
|
73
|
+
<https://euromod-web.jrc.ec.europa.eu/download-euromod>.
|
|
74
|
+
|
|
75
|
+
## The canonical shock table
|
|
76
|
+
|
|
77
|
+
Every external model's output is normalised into one table before anything else happens. Six
|
|
78
|
+
columns, one row per shock:
|
|
79
|
+
|
|
80
|
+
| column | meaning |
|
|
81
|
+
|---|---|
|
|
82
|
+
| `channel` | how it acts: `align` (move people between states), `scale` (multiply a variable), `constant` (override a model parameter) |
|
|
83
|
+
| `metric` | what it acts on: `employment`, `unemployment`, an input variable (`yem`), an income list (`ils_udb_yem`), or a constant name (`$f_cpi`) |
|
|
84
|
+
| `group` | which people: a population cell over EUROMOD input variables — `"deh=3-4;dgn=1"`, `""` for everyone |
|
|
85
|
+
| `period` | the external model's period label |
|
|
86
|
+
| `op` | `set` \| `grow` \| `mult` \| `add` |
|
|
87
|
+
| `value` | the number |
|
|
88
|
+
|
|
89
|
+
Shock tables are content-addressed (`shk_…`), so the same economic scenario always has the same
|
|
90
|
+
id regardless of which file or code path produced it.
|
|
91
|
+
|
|
92
|
+
Population cells are written over *real EUROMOD input variables*, never invented category labels.
|
|
93
|
+
`region` is the one named dimension and is NUTS-aware: coarser codes cover their subregions, and
|
|
94
|
+
shocks defined at a finer level than the data supports are collapsed to the level it does.
|
|
95
|
+
|
|
96
|
+
## Two entry points
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
import pandas as pd
|
|
100
|
+
from euromod import Model
|
|
101
|
+
from euromod_linking import apply_scenario, run_scenario
|
|
102
|
+
|
|
103
|
+
system = Model(r"C:\EUROMOD_RELEASES").countries["BE"].systems["BE_2025"]
|
|
104
|
+
|
|
105
|
+
scenario = {
|
|
106
|
+
"country_code": "BE",
|
|
107
|
+
"system_name": "BE_2025",
|
|
108
|
+
"shocks": {"inline": [
|
|
109
|
+
{"channel": "align", "metric": "employment", "group": "deh=0-3",
|
|
110
|
+
"period": "1", "op": "grow", "value": 0.0655},
|
|
111
|
+
]},
|
|
112
|
+
"params": {"period": "1"},
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
# Pure transform: returns the counterfactual input, a matched baseline, and diagnostics.
|
|
116
|
+
plan = apply_scenario(system, pd.read_csv(data_file, sep="\t"), scenario)
|
|
117
|
+
|
|
118
|
+
# Convenience: does the above and runs both simulations.
|
|
119
|
+
out = run_scenario(system, scenario, input_path=r"C:\EUROMOD_RELEASES\Input")
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`apply_scenario(..., validate_only=True)` stops before the expensive work and returns what the
|
|
123
|
+
scenario *would* do: the per-cell baseline population the shocks resolve against, the resulting
|
|
124
|
+
targets, the implied change in people and in percentage points, and feasibility against the pool
|
|
125
|
+
of people who can actually move. Check a shock is the size you meant before paying for two
|
|
126
|
+
simulations.
|
|
127
|
+
|
|
128
|
+
External model output in a file is ingested through a declarative mapping spec — a YAML file
|
|
129
|
+
under `mappings/`, or a dict — rather than bespoke parsing code:
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
scenario["shocks"] = {"file": "projections.xlsx", "mapping": "regional_projections"}
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Methodologies
|
|
136
|
+
|
|
137
|
+
The transformation is **never chosen by the caller**. It is resolved from the shock channels and
|
|
138
|
+
echoed back, so a scenario cannot silently be handled by a different method than the one that
|
|
139
|
+
produced an earlier result. Their code is content-fingerprinted into the scenario id — changing the modelling invalidates cached results rather than serving stale
|
|
140
|
+
ones.
|
|
141
|
+
|
|
142
|
+
- **`lma_labour_alignment`** (`align`) — two-level hierarchical alignment to external
|
|
143
|
+
employment/unemployment totals per cell. Level 1 sizes the labour force, level 2 splits it into
|
|
144
|
+
employment and unemployment. Who moves is decided by ranked logit propensities, not a random
|
|
145
|
+
draw; targets are hit exactly by splitting the boundary household's weight. New workers are
|
|
146
|
+
given full-time earnings at their own predicted hourly wage. Labour states come from `les`/`les2`
|
|
147
|
+
over working age (18–65), and only genuinely inactive people are recruitable — students,
|
|
148
|
+
pensioners, the long-term sick and conscripts are never moved.
|
|
149
|
+
- **`scale_variables`** (`scale`) — cell-level scaling of input variables. An income-list metric
|
|
150
|
+
is expanded extension-aware into its component variables by walking the model's `DefIl`
|
|
151
|
+
definitions, so it stays correct when extensions change what a list contains.
|
|
152
|
+
|
|
153
|
+
## Diagnostics
|
|
154
|
+
|
|
155
|
+
Every run reports the baseline it worked from, not just what it achieved: per-cell population and
|
|
156
|
+
labour states, the resolved target, the change in people *and* percentage points, feasibility
|
|
157
|
+
against the recruitable pool, and transitions as **weighted people** alongside raw row counts.
|
|
158
|
+
An alignment grade says only that the target was hit — never that the target was right — so the
|
|
159
|
+
baseline is always reported beside it.
|
|
160
|
+
|
|
161
|
+
## Tests
|
|
162
|
+
|
|
163
|
+
```bash
|
|
164
|
+
pip install -e .[dev]
|
|
165
|
+
pytest
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
## Licence
|
|
169
|
+
|
|
170
|
+
EUPL-1.2.
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
# euromod-linking
|
|
2
|
+
|
|
3
|
+
Connect external economic models to [EUROMOD](https://euromod-web.jrc.ec.europa.eu/) by
|
|
4
|
+
transforming its input microdata and run parameters.
|
|
5
|
+
|
|
6
|
+
A macro model — a CGE model, a forecasting model, a policy scenario written by hand — projects
|
|
7
|
+
*changes*: employment by region and education, nominal wages, price levels. EUROMOD simulates
|
|
8
|
+
taxes and benefits on a household survey. This package is the layer between them: it takes those
|
|
9
|
+
projected changes as data, rewrites the microdata and run parameters so the survey population
|
|
10
|
+
matches them, and runs baseline and counterfactual simulations that differ *only* by the shock.
|
|
11
|
+
|
|
12
|
+
It is a standalone library. It has no dependency on any agent, notebook or UI, and is usable
|
|
13
|
+
directly from a script.
|
|
14
|
+
|
|
15
|
+
## Scope
|
|
16
|
+
|
|
17
|
+
**This library targets the JRC's EUROMOD model for the 27 EU member states, and only that
|
|
18
|
+
model.** It is not a general library for the EUROMOD *software*: models built on the same
|
|
19
|
+
engine — SOUTHMOD, SWISSMOD, and national or regional models outside the EU — will not work
|
|
20
|
+
with it.
|
|
21
|
+
|
|
22
|
+
It assumes EUROMOD's own EU-27 conventions throughout: the `ils_udb_*` User Database income
|
|
23
|
+
lists, the `les`/`les2` labour-status codings, `drgn1`/`drgn2` read as NUTS regions, variable
|
|
24
|
+
names such as `dwt`, `dag`, `deh`, `yem` and `yivwg`, the `$lhw` constant, and the
|
|
25
|
+
JRC-maintained LMA add-on. Those conventions are precisely what a different model changes.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
pip install euromod-linking # or: pip install -e .
|
|
31
|
+
pip install euromod-linking[excel] # to ingest .xlsx/.xlsm/.xls model output
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Requires Python 3.11+ and a local EUROMOD model and installation (see the `euromod` connector).
|
|
35
|
+
The model is distributed by the JRC and can be requested at
|
|
36
|
+
<https://euromod-web.jrc.ec.europa.eu/download-euromod>.
|
|
37
|
+
|
|
38
|
+
## The canonical shock table
|
|
39
|
+
|
|
40
|
+
Every external model's output is normalised into one table before anything else happens. Six
|
|
41
|
+
columns, one row per shock:
|
|
42
|
+
|
|
43
|
+
| column | meaning |
|
|
44
|
+
|---|---|
|
|
45
|
+
| `channel` | how it acts: `align` (move people between states), `scale` (multiply a variable), `constant` (override a model parameter) |
|
|
46
|
+
| `metric` | what it acts on: `employment`, `unemployment`, an input variable (`yem`), an income list (`ils_udb_yem`), or a constant name (`$f_cpi`) |
|
|
47
|
+
| `group` | which people: a population cell over EUROMOD input variables — `"deh=3-4;dgn=1"`, `""` for everyone |
|
|
48
|
+
| `period` | the external model's period label |
|
|
49
|
+
| `op` | `set` \| `grow` \| `mult` \| `add` |
|
|
50
|
+
| `value` | the number |
|
|
51
|
+
|
|
52
|
+
Shock tables are content-addressed (`shk_…`), so the same economic scenario always has the same
|
|
53
|
+
id regardless of which file or code path produced it.
|
|
54
|
+
|
|
55
|
+
Population cells are written over *real EUROMOD input variables*, never invented category labels.
|
|
56
|
+
`region` is the one named dimension and is NUTS-aware: coarser codes cover their subregions, and
|
|
57
|
+
shocks defined at a finer level than the data supports are collapsed to the level it does.
|
|
58
|
+
|
|
59
|
+
## Two entry points
|
|
60
|
+
|
|
61
|
+
```python
|
|
62
|
+
import pandas as pd
|
|
63
|
+
from euromod import Model
|
|
64
|
+
from euromod_linking import apply_scenario, run_scenario
|
|
65
|
+
|
|
66
|
+
system = Model(r"C:\EUROMOD_RELEASES").countries["BE"].systems["BE_2025"]
|
|
67
|
+
|
|
68
|
+
scenario = {
|
|
69
|
+
"country_code": "BE",
|
|
70
|
+
"system_name": "BE_2025",
|
|
71
|
+
"shocks": {"inline": [
|
|
72
|
+
{"channel": "align", "metric": "employment", "group": "deh=0-3",
|
|
73
|
+
"period": "1", "op": "grow", "value": 0.0655},
|
|
74
|
+
]},
|
|
75
|
+
"params": {"period": "1"},
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
# Pure transform: returns the counterfactual input, a matched baseline, and diagnostics.
|
|
79
|
+
plan = apply_scenario(system, pd.read_csv(data_file, sep="\t"), scenario)
|
|
80
|
+
|
|
81
|
+
# Convenience: does the above and runs both simulations.
|
|
82
|
+
out = run_scenario(system, scenario, input_path=r"C:\EUROMOD_RELEASES\Input")
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`apply_scenario(..., validate_only=True)` stops before the expensive work and returns what the
|
|
86
|
+
scenario *would* do: the per-cell baseline population the shocks resolve against, the resulting
|
|
87
|
+
targets, the implied change in people and in percentage points, and feasibility against the pool
|
|
88
|
+
of people who can actually move. Check a shock is the size you meant before paying for two
|
|
89
|
+
simulations.
|
|
90
|
+
|
|
91
|
+
External model output in a file is ingested through a declarative mapping spec — a YAML file
|
|
92
|
+
under `mappings/`, or a dict — rather than bespoke parsing code:
|
|
93
|
+
|
|
94
|
+
```python
|
|
95
|
+
scenario["shocks"] = {"file": "projections.xlsx", "mapping": "regional_projections"}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Methodologies
|
|
99
|
+
|
|
100
|
+
The transformation is **never chosen by the caller**. It is resolved from the shock channels and
|
|
101
|
+
echoed back, so a scenario cannot silently be handled by a different method than the one that
|
|
102
|
+
produced an earlier result. Their code is content-fingerprinted into the scenario id — changing the modelling invalidates cached results rather than serving stale
|
|
103
|
+
ones.
|
|
104
|
+
|
|
105
|
+
- **`lma_labour_alignment`** (`align`) — two-level hierarchical alignment to external
|
|
106
|
+
employment/unemployment totals per cell. Level 1 sizes the labour force, level 2 splits it into
|
|
107
|
+
employment and unemployment. Who moves is decided by ranked logit propensities, not a random
|
|
108
|
+
draw; targets are hit exactly by splitting the boundary household's weight. New workers are
|
|
109
|
+
given full-time earnings at their own predicted hourly wage. Labour states come from `les`/`les2`
|
|
110
|
+
over working age (18–65), and only genuinely inactive people are recruitable — students,
|
|
111
|
+
pensioners, the long-term sick and conscripts are never moved.
|
|
112
|
+
- **`scale_variables`** (`scale`) — cell-level scaling of input variables. An income-list metric
|
|
113
|
+
is expanded extension-aware into its component variables by walking the model's `DefIl`
|
|
114
|
+
definitions, so it stays correct when extensions change what a list contains.
|
|
115
|
+
|
|
116
|
+
## Diagnostics
|
|
117
|
+
|
|
118
|
+
Every run reports the baseline it worked from, not just what it achieved: per-cell population and
|
|
119
|
+
labour states, the resolved target, the change in people *and* percentage points, feasibility
|
|
120
|
+
against the recruitable pool, and transitions as **weighted people** alongside raw row counts.
|
|
121
|
+
An alignment grade says only that the target was hit — never that the target was right — so the
|
|
122
|
+
baseline is always reported beside it.
|
|
123
|
+
|
|
124
|
+
## Tests
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
pip install -e .[dev]
|
|
128
|
+
pytest
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Licence
|
|
132
|
+
|
|
133
|
+
EUPL-1.2.
|