This repository contains the code and data for reproducing the results in Paluck, Porat, Clark and Green (2020).
From the project root directory, execute either Rscript 0-main.R or, if you prefer, bash run.sh.
0-main.R - Runs the entire pipeline from the top (R scripts 1-6, in order) and creates all output.
1-clean-data.R - Cleans and transforms raw_data.csv into prejudice_meta_data.rds.
2-cohens-d.R - Converts the unstandardized effects into Cohen's D, variance of D, and Standard Error of D, and appends estimates of each to the main dataset.
3-sub-group.R - Calculates all meta-analytic effect sizes that are presented in the paper and saves them as csv files within (subfolders of) data/meta-analytic/*.
4-paper-stats.Rmd - Provides code and data that produce each quantitative claim in the paper. It builds on 3-sub-group-R, so if the csv files created by that script haven't yet been created, this script will not run.
5-figures.Rmd - The creates all the figures used in the paper and some additional exploratory visualizations.
6-methods-check.Rmd - This script simulates a dataset and uses it to check the paper's procedures for estimating Cohen's D.
run.sh - A bash script that executes 0-main.R (which runs all scripts in order).
prejudice_reduction.Rproj - An R project file used to navigate directories for reproduciblity across machines.
dplot.R - A function for creating scatterplots of D by N_treatment (used in 5-figures.Rmd).
factor-levels.R - Declares the names of the numeric variable categories so that they can be converted to factors.
forest_functions.R - Additional functions for the forest plots in 5-figures.Rmd.
main-meta-function.R - Declares the function meta_analyze, which is used to calculate the meta-analytic effects in 3-sub-group.R.
make_bib.R - Provides examples of how to use RefManageR to convert DOIs in a dataset into a complete bibliography.
ResultsStandardizeR.R - Declares the function stand_result, used primarily in the script 2-cohens-d.R to convert unstandardized effect sizes into Cohen's D.
write_dockerfile.R - Converts the output from sessioninfo::package_info() into a Dockerfile for long-term reproducibility.
These files are included in the repository and serve as inputs to the analysis:
raw-data.csv - The raw meta-analysis data. This is the primary input file that gets transformed by the analysis scripts.
lai_data.rds - A dataset of estimates from Lai et al. (2014, 2016) used in a robustness check discussed in the appendix.
sim_data.rds - Simulated data for validating the methods in 6-methods-check.Rmd.
These files are created when you run the analysis and are not included in the repository:
prejudice_meta_data.rds - The main dataset used in the meta-analysis. Created by 1-clean-data.R (which transforms raw-data.csv) and then enhanced by 2-cohens-d.R (which appends Cohen's D, variance of D, and standard error of D). A data dictionary of the variables can be found in documentation/.
prejudice_meta_data.dta - Stata 15 version of prejudice_meta_data.rds, for users who prefer Stata.
meta-analytic/* - Intermediate datasets containing meta-analytic results, created by 3-sub-group.R.
all-manuscripts-bibliography.bib, all-manuscripts-bibliography.pdf - A .bib file (and compiled PDF) of the 309 manuscripts in the main meta-analysis.
codebook.csv - a codebook for all variables in raw-data.csv.
Dockerfile -- A Dockerfile for long-term reproducibility. This file is automatically generated at the end of the analysis pipeline by 0-main.R (which calls functions/write_dockerfile.R). The Dockerfile captures all loaded packages with their specific versions and uses a version-specific R base image (e.g., rocker/r-base:4.4.1 rather than :latest).
Note on Dockerfile generation: The Dockerfile is generated after running the full analysis pipeline, ensuring all necessary packages are loaded and captured. If you modify the analysis or add new packages, simply re-run Rscript 0-main.R to regenerate an updated Dockerfile. Alternatively, you can regenerate it manually by loading your packages and then running:
source('./functions/write_dockerfile.R')
write_dockerfile(dir = 'documentation/')