An agent-based model simulating the UK population, focusing on the effects of inherited wealth.
- Python 3.6
- Packages listed in
requirements.txt
Before your first run, initialise the data:
make data
or
python data.py
To run the simulation:
make run
or
python adapter.py model.yaml
Running the simulation produces an output.h5
HDF5 file, containing the following tables:
data
: top-level data at each tick (year) of the simulationby_age
: data subdivided by the age of the agents, at each tickhistory
: full history of each agent through the simulationskill_dist
: number of agents at each skill level at each ticktree
: full list of family links between pairs of agentstrusts
: data on each inheritance trust at each tick
A function is provided for plotting the life history of an individual agent:
import pandas as pd
import sinks
data = pd.HDFStore('output.h5')
sinks.plot_history(data, 123)
Parameters of the model are set in model.yaml
. Under control_parameters
you can set the number of ticks
and number of agents
. The available model_parameters
are:
inheritance
: type of inheritance, "direct" or "trust"trust_first_generation
: first generation to benefit from trusts (1 = children)trust_last_generation
: last generation to benefit from trusts (1 = children)assortative_mating
: strength of assortative mating (0 = none, 1 = very strong)savings_rate
: fraction of income that gets savedinterest_rate
: interest rate for wealth and trusts
README.md
: this filerequirements.txt
: python packages requiredraw_data/*/*.xls
: raw data from the ONS and censusdata.py
: script for processing raw data into numpy arraysmodel.yaml
: model specificationinheritance.py
: core model logicadapter.py
: wrapper forinheritance.py
that loads in the data and parametersscenarios.py
: initialises agent populationsinks.py
: processes output data
PyData London 2017