Trust and Social Control: Sources of cooperation, performance, and stability in informal value transfer systems
Claudius Gräbner, Wolfram Elsner and Alex Lascaus
This repository contains the source code for the model used in the abovementioned paper. The paper is published in the journal Computational Economics and is available here (open access, main paper and supplementary material).
bash
: contains bash scripts to run the simulation with particularly relevant parameter combinations (not necessary any more)
python
: contains all Python scripts and, in python/parameters/
the json files containing relevant parameter specifications.
notebooks
: contains Python notebooks, including the one used to create the figures for the final paper
tex
: contains TeX code used to create some of the figures in the final paper
output
: contains all the output produced by the source code
The general functioning of the model is explained in the main paper. Moreover, the code is well documented and should be largely self-explanatory. The general structure and the main elements of the model are as follows:
- The parameter files saved in
python/parameters/
. These are json files specifying all relevant model parameters. If a parameter value is given as alist
and the model is called viaMain
, then the model is run for all possible parameter constellations for those specified in the lists.- For example, if the parameter
C_trust
is specified as[0, 1]
andC_control_1
as[0, 1]
, then calling this parameter file means to runs one model instance withC_trust=1
andC_control_1=1
, one withC_trust=0
andC_control_1=1
, one withC_trust=0
andC_control_1=1
, and one withC_trust=0
andC_control_1=0
.
- For example, if the parameter
- The main model is implemented via the class
Model
, which is defined inmodel.py
. Some parts were sourced out in separate files:- During the initialization of a
Model
, an initial agent population must be set up. This is done by the classPopulationGenerator
, which is defined inpopulation_generator.py
. - The class
Agent
is defined inagent.py
. - The strategies of the agents are defined via their own class
Strategy
. This class is defined instrategies.py
.
- During the initialization of a
- The class
Main
, which is defined inmain.py
reads a parameter file, creates many instances ofModel
, runs these models and summarizes their results in a single data frame. - The function
conduct_meta_mcs()
as defined inMCS.py
facilitates Monte Carlo simulations. When it is called one has to supply the skeleton of the names of parameter files. Thenmain.py
is executed for all parameter files matching this name and the results are aggregated into a single data frame that can then be further processed.
Thus, the recommended way to use the model is via MCS.py
. To run the model for all parameter constellations that are specified in the parameter files starting with 'hawala_shocks' we can use the following call:
python python/MCS.py python/parameters/hawala_shocks 10
This runs the model 10 times for each of the following parameter files: hawala_shocks_c.json
, hawala_shocks_t.json
and hawala_shocks_tc.json
, and aggregates the results into a single data frame.
There are three ways to run the model:
-
Conduct a single model run using
model.py
directly. This only works for a single parameter constellation and is not recommended. -
Run the same model for many times using
main.py
. This allows to sweep through different parameter constellations if the different parameter values are specified as alist
in the json file. -
Run the model for several parameter constellation using
MCS.py
. This is the recommended way to use the model and effectively callsmain.py
several times and can process more than one parameter file.
To replicate the figures in the main paper you must first create the data by runing the following simulations.
For figure 5:
python python/MCS.py python/parameters/hawala_baseline 30
For figures 6 and 7:
python python/MCS.py python/parameters/hawala_shocks 30
For figure 8:
python python/MCS.py python/parameters/hawala_framework_nbhawaladars 30
and
python python/MCS.py python/parameters/hawala_framework_intdensity 30
For figure 9:
python python/MCS.py python/parameters/hawala_framework_forgiveness 30
For figure 10:
python python/MCS.py python/parameters/hawala_framework_pop_growth 30
For figure 11:
python python/MCS.py python/parameters/hawala_framework_mistakes 30
Then you can use the Python Notebook in notebooks/Create-Figures.ipynb
to create all the figures. They are automatically saved to output/figures
.
In case you have questions, feedback or other comments feel free to contact Claudius here.