Repduction package downloaded at https://www.google.com/url?q=https%3A%2F%2Fwww.dropbox.com%2Fs%2F0o0win60iwsdnyl%2FPolarization_PublicHealth_Replication.zip%3Fdl%3D0&sa=D&sntz=1&usg=AFQjCNFoYC1NL9027dvozCiDsJBCDP7CCw
Full paper (with appendices) availiable at https://www.nber.org/system/files/working_papers/w26946/w26946.pdf
No changes made to package (3/1/2021)
The results in "Polarization and Public Health: Partisan Differences in Social Distancing During the Coronavirus Pandemic" can be reproduced by completing the following steps:
-
Ensure that your computing environment satisfies the Requirements section below.
-
Download the data described in the External Data section to your local computer.
-
Complete the steps described in the Setup section.
-
Run
python run_all.pyfrom the root of the repository (as described in the Build section).
The final paper will then be produced at paper_slides/output/paper.pdf.
This repository is structured as follows:
setup/contains programs to download required packages and otherwise assist in setup.raw/contains raw data used elsewhere in the repo.data/contains code and output related to the cleaning of datasets.analysis/contains code and output related to the analysis of cleaned data.paper_slides/contains code and output related to paper production itself, using the output produced inanalysis.lib/stores programs used to facilitate running the repository, including tools to link together different modules (egdata/andanalysis/).
All requirements must be installed and set up for command line usage. For further detail, see the Command Line Usage section below.
- Python (2.7/3.7)
- pip (>=10.0)
To build the repository as-is, the following applications are additionally required:
- git-lfs
- LyX
- R
- Stata
These software are used by the scripts contained in the repository. By default, the Setup and Build instructions below will assume their usage.
In addition to the data contained in this repository, reproduction requires access to the following pieces of data:
- SafeGraph: Including SafeGraph's Monthly Patterns, Weekly Pattterns, Daily Social Distancing, Open Census, and Places datasets. Also includes cleaned weather data shared with the SafeGraph consortium by Jude Bayham. For the required folder structure of an external SafeGraph data folder, see
data/external.txt. - Precinct Shapefiles: Can be downloaded from https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/NH5S2I
- Census Block Group Shapefiles: Can be downloaded by state from ftp://ftp2.census.gov/geo/tiger/TIGER2019/BG/
If you are using Windows, you may need to run certain bash commands in administrator mode due to permission errors. To do so, open your terminal by right clicking and selecting Run as administrator. To set administrator mode on permanently, refer to the RA manual.
-
Create a
config_user.yamlfile in the root directory. A template can be found in thesetupsubdirectory. See the User Configuration section below for further detail. -
Install
spatialindex, to be used in mapping programs. This can be done for example with Homebrew by runningbrew install spatialindexin a terminal. -
Install Python dependencies listed in the
requirements.txtfile using pip. One way to do this is to run the following bash command in a terminal from thesetupsubdirectory:python -m pip install --user -r requirements.txt -
Run the
check_setup.pyfile. One way to do this is to run the following bash command in a terminal from thesetupsubdirectory:python check_setup.py -
Install Stata dependencies using the
setup_stata.dofile. One way to do this is to use the following bash command from thesetupsubdirectory:stata-mp -e setup_stata.doIf you are using a Windows, you will likely have to adjust this bash command:
stata_executable -e setup_stata.dostata_executablerefers to the name of your Stata executable. For example, if your Stata executable was located inC:\Program Files\Stata15\StataMP-64.exe, you would want to use the following bash command:StataMP-64 -e setup_stata.do -
Install R dependencies using the
setup_r.rfile. One way to do this is to run the following bash command in a terminal from thesetupsubdirectory:Rscript setup_r.r -
Install the libspatialindex library: If you use homebrew, this can be done via
brew install spatialindex.
If you are using Windows, you may need to run certain bash commands in administrator mode due to permission errors. To do so, open your terminal by right clicking and selecting Run as administrator. To set administrator mode on permanently, refer to the RA manual.
-
Follow the Setup instructions above.
-
From the root of repository, run the following bash command:
python run_all.py
For specific instructions on how to set up command line usage for an application, refer to the RA manual.
By default, the repository assumes the following executable names for the following applications:
application : executable
python : python
git-lfs : git-lfs
lyx : lyx
r : Rscript
stata : statamp (will need to be updated if using a version of Stata that is not Stata-MP)
These are the standard executable names for Mac and are likely to differ on your computer if you are using Windows. Executable names for Windows will typically look like the following:
application : executable
python : python
git-lfs : git-lfs
lyx : LyX#.# (where #.# refers to the version number)
r : Rscript
stata : StataMP-64 (will need to be updated if using a version of Stata that is not Stata-MP or 64-bit)
Default executable names can be updated in config_user.yaml. For further detail, see the User Configuration section below.
config_user.yaml contains settings and metadata such as local paths that are specific to an individual user and thus should not be committed to Git. For this repository, this includes local paths to external dependencies as well as executable names for locally installed software.
Required applications may be set up for command line usage on your computer with a different executable name from the default. If so, specify the correct executable name in config_user.yaml. This configuration step is explained further in the RA manual.