Replication code for the paper:
Isaac Slaughter, Axel Peytavin, Johan Ugander, and Martin Saveski (2025) "Community notes reduce engagement with and diffusion of false information online," PNAS.
- Download data here and place it in the
datadirectory. - Install python and R dependencies listed in
requirements.txtandrenv.lock. - Run the pipeline using one of the scripts in
src/runner. For example, for the main analysis in the paper, runbash src/runner/main.sh. - Run
python src/analysis/plot_final_figures.pyto generate the figures in the paper, ormarimo edit src/analysis/paper_stats.pyto generate the statistics in the paper.
Replication data for this project is available for download here.
Source code for this project is available in the src directory. The code is organized as follows:
src/pipelinecontains scripts for estimating treatment effects with synthetic controls.src/analysiscontains scripts for summarizing these effects and analyzing heterogeneity within them.src/configcontains JSON files for running the pipeline under the various configurations we consider in the paper.src/runnercontains shell scripts for running the pipeline.
The following scripts contain code for calculating the statistics and artifacts used in the paper:
src/analysis/paper_stats.pysrc/analysis/plot_final_figures.pysrc/analysis/gather_cate_data.py
- The code was designed to run on single high-memory machine. It took multiple days to run the main pipeline, and will take longer for the runs discussed in the supplementary information.
- Each script in the
pipelinefolder has a parameter for specifying the number of threads/workers/processes to use, which you can modify for your setting. - There are some sources of stochasticity in the pipeline—for example there are non-unique solutions to some of the quadratic programs that are solved when constructing synthetic controls. This can lead to small differences in results between runs. (We observed a maximum relative change of 2% when rerunning the pipeline.) Please feel free to reach out to the corresponding author with any questions.
If you use this code in your research, please cite the following paper:
@article{
doi:10.1073/pnas.2503413122,
author = {Isaac Slaughter and Axel Peytavin and Johan Ugander and Martin Saveski},
title = {Community notes reduce engagement with and diffusion of false information online},
journal = {Proceedings of the National Academy of Sciences},
volume = {122},
number = {38},
pages = {e2503413122},
year = {2025},
doi = {10.1073/pnas.2503413122},
}