Skip to content

Code and data for People construct simplified mental representations to plan

Notifications You must be signed in to change notification settings

xhb120633/value-guided-construal

 
 

Repository files navigation

Value-guided construal

This repository contains code for the paper People construct simplified mental representations to plan by Ho, Abel, Correa, Littman, Cohen, and Griffiths.

It is organized into the following subdirectories:

  • experiment.psiturkapp contains code for running the experiments using the psiturk framework (see here).
  • experiments includes data and code for generating experimental trials
  • analyses includes notebooks and scripts for analyses in the paper
  • vgc_project is a python package that analyses and modeling depend on
  • modeling includes modeling code that is not directly related to the experiments

It is also linked to this OSF repository.

Set up

The project uses Python 3 (everything works with 3.7). One way to use it is by setting up a virtualenv:

$ virtualenv -p python3 env
$ source env/bin/activate
(env)$ env/bin/pip install -r requirements.txt

You need to also install the vgc_project package into the virtual environment (the -e flag installs it in editable mode):

(env)$ env/bin/pip install -e ./vgc_project

Running analyses

Once you have a python environment set up, the projects.py script can be used to run various analysis scripts and notebooks for the experiments.

First, unzip all the datafiles:

$ python project.py unzip_files

Then, run the analysis notebooks (this could take awhile the first time but afterwards various computations will be cached):

$ python project.py run_analysis_notebooks

The analysis notebooks are all included in analyses/.

Replicability

You may have to set the PYTHONHASHSEED variable to 0 to replicate certain analyses. See here.

Analyses with lme4

Some of the hierarchical generalized linear regression analyses are done using the lme4 package in R. The vgc_project.r module provides wrappers that interface with R using the rpy2 package (see here). This requires installing R.

Note: I have found that rpy2 will not install on python 3.9 on OSX.

Code for models

All the code for the value-guided construal model and alternative models is organized in the vgc_project package folder. Several of the models rely on code from the msdm (version 0.6) python package, which is automatically installed via pip using the instructions above.

Running/demoing experiments

Testing locally

You can run the code in experiment.psiturkapp as a psiturk experiment by doing the following:

$ cd experiment.psiturkapp
$ make dev

This creates a server at http://localhost:22362. Specific experiments can be demoed at the following links once you have the server running:

About

Code and data for People construct simplified mental representations to plan

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 93.7%
  • JavaScript 3.5%
  • Python 2.5%
  • HTML 0.2%
  • CSS 0.1%
  • Makefile 0.0%