14
LIAM 2: A NEW OPEN SOURCE DEVELOPMENT TOOL FOR THE DEVELOPMENT OF DISCRETE-TIME DYNAMIC MICROSIMULATION MODELS PHILIPPE LIÉGEOIS (CEPS/INSTEAD, Luxembourg and DULBEA, ULB, Brussels) GAËTAN DE MENTEN (FEDERAL PLANNING BUREAU, BRUSSELS) GIJS DEKKERS (FEDERAL PLANNING BUREAU, BRUSSELS, CENTRE FOR SOCIOLOGICAL RESEARCH, K.U.LEUVEN AND CEPS/INSTEAD) RAPHAËL DESMET (FEDERAL PLANNING BUREAU) European Meeting of the IMA Dublin, 17-19 May 2012 IGSS Luxembourg

LIAM 2: A NEW OPEN SOURCE DEVELOPMENT TOOL FOR THE DEVELOPMENT OF DISCRETE-TIME DYNAMIC MICROSIMULATION MODELS PHILIPPE LIÉGEOIS (CEPS/INSTEAD, Luxembourg

Embed Size (px)

Citation preview

LIAM 2: A NEW OPEN SOURCE DEVELOPMENT TOOL

FOR THE DEVELOPMENT OF DISCRETE-TIME DYNAMIC MICROSIMULATION MODELS

PHILIPPE LIÉGEOIS (CEPS/INSTEAD, Luxembourg and DULBEA, ULB, Brussels)

GAËTAN DE MENTEN (FEDERAL PLANNING BUREAU, BRUSSELS)GI JS DEKKERS (FEDERAL PLANNING BUREAU, BRUSSELS,

CENTRE FOR SOCIOLOGICAL RESEARCH, K.U.LEUVEN AND CEPS/INSTEAD)

RAPHAËL DESMET (FEDERAL PLANNING BUREAU)European Meeting of the IMA

Dubl in, 17-19 May 2012

IGSS Luxembourg

2

INTRODUCTION

LIAM2 is a new tool for the development of (large scale) dynamic microsimulation models (prospective as well as retrospective) with dynamic cross-sectional ageing (but also static models as a by-product)

User-friendly and effi cient (developed in Python with use of the Hierarchichal Data Format HDF5 for data storage, but this is fully transparent to the modeller)

The result of a collaboration between the Federal Planning Bureau in Brussels (development), the CEPS/INSTEAD and the General Inspectorate of Social Security in Luxembourg (testing and complementary funding) and Cathal O’Donoghue (LIAM and expertise) as well as other experts, under European funding (MiDaL Project 2009-2011, PROGRESS programme, Grant VS/2009/0569)

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

3

CONTENTS OF THE PRESENTATION

LIAM2 : Objectives

Situating LIAM2 in the family of modelling packages

How to proceed with that Working environment (for those who know simply nothing about it) ?

Building and simulating a model in LIAM2 explained in 10 minutes

Conclusions

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

4

LIAM2 : OBJECTIVES

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

A development framework for the modelling and simulation of large scale discrete-time dynamic microsimulation models with cross-sectional dynamic ageing and alignment

A user-friendly and effi cient development framework :

A clear separation (like in LIAM) between “modellers” (responsible for the modelling) and “programmers” (in charge of the development of critical methodological issues, including state-of-the-art methods for data-handling and simulation optimization)

Implementation of language which is easy to use for the modellers

Stimulate collaboration between development teams through the use of a common development approach (EURODYM)

Be open source, so that developers worldwide may add to the toolbox and make accessible their own modules when relevant for the community

5

SITUATING LIAM2

Developed based on the experience gained through LIAM in the development of the MIDAS model (Federal Planning Bureau),but more general, faster, allowing for much larger datasets, etc

Does not require any programming in C++ (and buying Visual Studio) like ModGen which essentially a C++ library allowing for microsimulation (+/- like JAMSIM) and mainly developed for continuous-time modelling (agent-based models for JAMSIM)

LIAM2 is off ering its own (easy) syntax, is developed in Python and makes use (for effi ciency reasons) of HDF5 for data (but no consequence for the end user), is a generic package allowing for any kind of object (“entities”)

Compared to GENESIS… see the next presentation

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

6

LIAM2 : HOW TO PROCEED WITH THAT WORKING ENVIRONMENT ?

Download the LIAM2 bundle from http://liam2.plan.be/

The bundle includes :

The executable

A text editor (Notepad++), pre-configured to work with LIAM2

Documentation

A demonstration model (20,200 persons, 14,700 households)

Building and Simulating a Model in LIAM2 implies (classical !):

(A) Knowing more about the “bricks” available

(B) Preparing the input dataset

(C) Defining/writing the model

(D) Running, (E) Debugging and Storing the results

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

7

BUILDING AND SIMULATING A MODEL IN LIAM2 : (A) THE BRICKS

LIAM2 involving several kinds of « bricks », among which…

ENTITIES : objects (persons, households, fi rms, cell, …) with a unique identifier

FIELDS : attributes of an entity (e.g. person’s age)

LINKS : relation between entities (e.g. person’s children) ; can lead to subsequent use (e.g. spouse.mother.age)

GLOBALS : a parameter not related to a specifi c entity, may vary through time (e.g. CPI)

PROCESSES : assignments, which change the value of a variable (e.g. « age+1 ») using an expression, and actions which do not (e.g. remove dead person)

MACROS : piece of code, re-evaluated each time it is referenced (e.g. « WIDOW: civilstate == 5 »)

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

8

A MODEL IN LIAM2 : (B) PREPARING THE INPUT DATASET

For the moment, only from CSV fi les, one fi le for « globals » and one fi le for each entity

Create a description fi le, then run it (e.g. bundled editor, F5) => HDF5

Þ Input created« normal.h5 »

NB : This creation must be done only once(then LIAM2 reads the HDF5 input as it has been setearlier)

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

9

A MODEL IN LIAM2 : (C) DEFINING – THE GENERAL STRUCTURE

A model is typically composed of 3 main blocks…

« globals »

« entities » : including their fi elds, links and definition of processes (order not meaningful) and macros available for that kind of entity

« simulation » : including the general setup of the model, e.g. input, output, starting period of simulation, number of periods of simulation, etc

Within the blocks, indentation is meaningful (cf. YAML-markup language)

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

10

A MODEL IN LIAM2 : (C) DEFINING – A SIMPLE EXAMPLE

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

11

A MODEL IN LIAM2 : (C) DEFINING – ADDITIONAL FEATURES

Links are of « many2one » or « one2many » types

«  mc: (type: one2many, target: person, field: mother_id ) »

« pm: (type: many2one, target: person, field: mother_id)  »

LIAM2 allows for mathematical functions (e.g. « round(expr[, n])  »), conditional expressions (« if(...)  »), aggregate functions (« grpsum(earnings)

»), temporal functions (« duration(inwork) »), link functions (« sumlink(mc, age<12) »), random functions (« randint(0,10)  »), stochastic changes (« gender=choice([True,False], [0.51,0.49])  »), life-cycle functions (« new(person) »), matching functions (e.g. for marriage, matching individual from set 1 with individuals from set 2, following a particular order regarding set 1)

Alignment : « logit_regr(expr[, align=‘filename’)]) »

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

12

A MODEL IN LIAM2 : (D) RUNNING AND (E) DEBUGGING & OUTPUTTING

Run the model (e.g. bundled Notepad++ editor => F6)

Debugging e.g. through interactive console in the bundled editor

while running (error messages or intermediate results)

or at the end =>

Breakpoints (« breakpoint([period])  ») can be introduced in the model, which automatically launch the interactive console

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

13

A MODEL IN LIAM2 : (E) DEBUGGING & OUTPUTTING

Or debugging e.g. through the store and post-analysis of results in fi les

By default, in HDF5 format (which can be transformed in Stata, SAS, R, … formats)

But also to « csv » fi les :

csv('PERIOD=', period,dump(h_id, id, age, marst, s_id, ps.id,

agediff, agediff2, filter = (id<10)), suffix='AGEDIFF')

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg

14

CONCLUSIONS

LIAM2, a new development tool for the development of (large scale) static and discrete-time dynamic microsimulation models

User-friendly and Open source (low entry cost)

Effi cient, even if can still be improved, making profi t of state-of-the-art methods for data-handling and simulation methods, in a transparent way regarding the end-user (modeller)

In Belgium (MIDAS), 300,000 individuals over 60 years, 3500 lines of code, 142 parameters, 132 variables, 18 alignment processes, 14 CSV output files => 2 hours and 16 minutes

Operational already, under use or prior test in Belgium (MIDAS), Luxembourg (MIDAS_LU, partial), Japan, UK, and…

Just try it ! (and feeback welcome )

L I A M 2

P H I L I P P E L I É G E O I S ( C E P S / I N S T E A D E T D U L B E A ) - E U R O P E A N M E E T I N G I M A - D U B L I N - 1 8 M A Y 2 0 1 2

IGSS Luxembourg