Provide practical tools to start building trial-level psychological models of behavioral data.
- Defining various models for an Ultimatum Game dataset
- Simulating task data using the different models
- Determining 'model fit' (the similarity between observed data and a model). This will cover least squares, log likelihood, and choice rules.
- Fitting a model to task data using gradient descent
- Model comparison
- Posterior predictive checks
- Model/parameter recovery
- Model types (RL, utility, DDM, etc) – this is more like a bonus. We'll work with models relevant to the group.
- Install latest Python 3.x (not 2.x) using an Anaconda distribution at https://www.anaconda.com/distribution/#download-section. If you already have Anaconda on your computer (of any version), you can skip this step.
- Create a Python 3.7 environment called something like 'comp_model' using the command listed on this conda cheat sheet.
- Activate your environment, install the package manager PyPI in it using
conda install pip
, and then use PyPI to install (at least) the following packages: numpy, pandas, matplotlib, seaborn, scipy, jupyter. PyPI works in the following way:pip install <package_name> <package_name> <and so on...>
. - Create a clean folder for this tutorial,
cd
to the folder, and launch a Jupyter Notebook using the commandjupyter notebook
. - Make a new 'sandbox' notebook and get comfortable with behavioral data analysis in Python by attempting to do the following things: 1) generate some random data in two variables of equal length and make a scatter plot using matplotlib; 2) generate some data for a linear relationship between two variables (e.g. age and height of schoolchildren), put them in a Pandas dataframe with 2 named columns, and use Seaborn to create a scatterplot with regression line; 3) create a Pandas dataframe with height data for 5 age groups and use Seaborn to turn this into a barplot with errorbars and an overlaid stripplot or swarmplot. Google is your friend!
- Complete the numbered notebooks at your own pace, starting with the 'problems' notebook and checking your work in the 'solutions' counterpart.
Feel free to reach out with questions and comments via @jeroen_van_baar.
Daw, Nathaniel (2009). Trial-by-trial data analysis using computational models. http://www.princeton.edu/~ndaw/d10.pdf Wilson, R. C., & Collins, A. G. (2019). Ten simple rules for the computational modeling of behavioral data. ELife, 8(e49547). https://doi.org/10.31234/OSF.IO/46MBN
Den Ouden, Hanneke & Jill O'Reilly (2015). Models of learning. http://hannekedenouden.ruhosting.nl/RLtutorial/html/dataAnalysisTopPage.html [includes Matlab code]
Feel free to fork the project and submit pull requests to make changes or add modules. Many thanks!