Code and data for reproducing the analyses in the paper.
- Python 3.10+ with scientific packages (numpy, pandas, scipy, matplotlib, seaborn, jax)
- R 4.0+ with packages:
lme4,lmerTest,dplyr,tidyr,reticulate - Quarto 1.3+: https://quarto.org/
uv is a fast Python package manager that handles virtual environments automatically.
# Install Python dependencies (creates .venv automatically)
uv sync
# Install R packages
Rscript -e "install.packages(c('lme4', 'lmerTest', 'dplyr', 'tidyr', 'purrr', 'reticulate'))"# Create and activate a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Install R packages
Rscript -e "install.packages(c('lme4', 'lmerTest', 'dplyr', 'tidyr', 'purrr', 'reticulate'))"The Quarto notebooks use R's reticulate package to run Python code. You must tell R which Python to use by setting the RETICULATE_PYTHON environment variable.
# Set Python path and render all notebooks
RETICULATE_PYTHON=$(pwd)/.venv/bin/python quarto render analysis/model_analyses.qmd
RETICULATE_PYTHON=$(pwd)/.venv/bin/python quarto render analysis/behavioral_analyses.qmd
RETICULATE_PYTHON=$(pwd)/.venv/bin/python quarto render analysis/supplement.qmd# Export the variable for your shell session
export RETICULATE_PYTHON=$(pwd)/.venv/bin/python
# Then render notebooks without prefix
quarto render analysis/model_analyses.qmd
quarto render analysis/behavioral_analyses.qmd
quarto render analysis/supplement.qmd| Notebook | Description | Main outputs |
|---|---|---|
model_analyses.qmd |
Bayesian factor model | Figure 4, Figure 5 |
behavioral_analyses.qmd |
Mixed-effects models | Figure 2, Figure 3 |
supplement.qmd |
Supplementary analyses | SI figures and tables |
"Python specified in RETICULATE_PYTHON does not exist"
- Make sure you ran
uv syncorpip install -r requirements.txtfirst - Check the path:
ls -la .venv/bin/python - Use absolute path:
export RETICULATE_PYTHON=/full/path/to/shared-reality/.venv/bin/python
R can't find packages
- Install missing R packages:
Rscript -e "install.packages('package_name')"
JAX errors on Apple Silicon
- JAX should work out of the box on M1/M2 Macs with the dependencies specified
├── analysis/ # Quarto notebooks
│ ├── model_analyses.qmd # Bayesian factor model (Figure 4, 5)
│ ├── behavioral_analyses.qmd # Mixed-effects models (Figures 2, 3)
│ └── supplement.qmd # Supplementary analyses
├── data/ # Experimental data
│ ├── responses.csv # Main behavioral data
│ ├── questions.csv # Survey questions
│ └── llm_results/ # LLM prediction outputs
├── models/ # Computational model code
│ ├── model.py # Bayesian factor model
│ └── llm/ # LLM prediction pipeline
├── outputs/figures/ # Generated figures
├── pyproject.toml # Python dependencies (for uv)
└── requirements.txt # Python dependencies (for pip)