Code and data for "An Active Inference Model of Trust Game Behavior"
Description
This is a zipped version of the github reposiory and behavioral data for an Active Inference model of trust game behavior.
It contains the software for simulation, model inversion, model comparison, classification and parameter/ prediction recovery.
To use this code and reproduce any results or figures, follow the steps detailed in our readme file below.
Please bear in mind that use is permitted under a CC BY-NC 4.0 license (see repo and below for details).
# Code and repository for: Active Inference in Interpersonal Decision-making
Simulation and modelling of trust game behavior under active inference. For license information, see LICENSE.txt
## π¦ Installation
This repository is packaged as an editable installation. To reproduce the results and run the code, follow these steps:
### 1. Download and extract repository snapshot
Download the ```.tar``` archive from open_UMR:
https://doi.org/10.17192/openumr/407
Extract it like so:
```bash
tar -xzf pymdp_depression.tar
```
```bash
cd pymdp_depression
```
Note: this repo is distributed as a snapshot, so it is not connected to the development git with its messy history. If you wish to use version control, you will need to initialise a new git repo locally.
### 2. Create environment (conda)
This project uses a conda environment to ensure reproducibility. Create the exact environment I used from the provided ```.yml``` file. If you are on a windows machine, try using ```pymdp_env_incl_builds.yml```. In any case, ```pymdp_env``` will work nicely.
```bash
conda env create -f pymdp_env.yml
```
Then activate the environment:
```bash
conda activate pymdp_env
```
And start your ide from this environment.
### 3. Install the package
Navigate to the top-level repo that contains ```pyproject.toml`` and run
```bash
pip install -e .
```
### 4. Verify your installation
From your terminal, navigate to ```src/simulations``` and try running
```bash
python3 simulation_loop.py
```
## π Repo structure
The repo structure is shown below. All analyses are created within src/, and then most figures and plots are created in notebooks, using functions from model/vis.py.
```
βpymdp_depression/
βββ pyproject.toml # Project configuration and dependencies
βββ pymdp_env.yml # conda environment
βββ README.md # Project overview and instructions
βββ LICENSE.txt # License information
βββ .gitignore
βββ data/ # preprocessed datasets
βββ notebooks/ # Jupyter notebooks for analysis and plotting
β βββ ... # Ordered to follow figures/results in the manuscript
β βββ ... # Figure_SX: supplementary figures.
βββ src/
β βββ pymdp_depression/
β βββ model/ # Core generative model implementation
β βββ simulations/ # Simulation scripts and experiment logic
β βββ optimization/ # Parameter fitting and optimisation routines
β βββ recovery/ # Parameter recovery analyses
β βββ classification/ # Classification models and evaluation
β βββ model_comparison/ # Model comparison with RL, win-stay-lose-switch
```
## π Procedure
In general, to reproduce the analyses, follow these steps:
1. Run simulations from `src/pymdp_depression/simulations/`
2. Fit models using `src/pympd_depression/optimization/data_fitting.py` and the respective configuration yaml (this was done on HPC)
3. Generate figures using `notebooks/`
Further documentation and instructions can be found within the dedicated submodules, e.g. inside the recovery or model comparison modules.
## β€οΈ Citation
The manuscript is currently under review - the code may be updated in the process, in which case an updated repo will appear under the same doi. Publicaton will appear here: https://eckertal.github.io/personal-website/publications/
License
Except where otherwise noted, this item's license is described as Attribution 4.0 International
