Skip to content

SocialInteractionLab/shared-reality

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

94 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Commonality inferences

Code and data for reproducing the analyses in the paper.

Requirements

  • 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/

Setup

Option 1: Using uv (recommended)

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'))"

Option 2: Using pip

# 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'))"

Reproducing Analyses

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.

Quick start

# 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

Alternative: Export once per session

# 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

Individual notebooks

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

Troubleshooting

"Python specified in RETICULATE_PYTHON does not exist"

  • Make sure you ran uv sync or pip install -r requirements.txt first
  • 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

Structure

├── 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)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages