This repository contains data, code, and manuscript source for the paper "A Measurement Gap? Effect of Survey Instrument and Scoring on the Partisan Knowledge Gap". The code for this paper is written in R and Stata (Python sparingly). The manuscript in pdf is compiled using LaTeX. The manuscript and the key results can be reproduced either by running the scripts directly or using the makefiles make
utilities.
The Overleaf repository for the manuscript is linked to its own GitHub repository and included as a Git submodule in this repository. See ./overleaf-partisan-gap/
. When cloning or pulling this repo, the submodule metadata (via .gitsubmodules
) and the folder for the manuscript submodule are included. However, the actual contents of the manuscript are not included. To get the contents, cd
into overleaf-partisan-gap/
submodule folder, do a git submodule init
and then git submodule update
.
The ./Makefile
includes a recipe to update all output of scripts into the ./overleaf-partisan-gap/
submodule folder. Type make update
to do so. The ./overleaf-partisan-gap/
repository also includes a Makefile to compile the manuscript in LaTeX and clean up auxiliary files using latexmk
. Type make ms
from ./overleaf-partisan-gap/
to compile the manuscript.
See here for the tables (TeX) and here for the figures (pdf, png).
All scripts (R, Stata, Python) are in scripts/
. The scripts to prepare the raw data for downstream analyses are mainly in R. See for example the R script to output the data required for Study 1 (MTurk sample 1) analyses. See here for key data files.
The Stata scripts are in scripts/Stata/
. Each of the four studies has its own subfolder with the relevant do
files. But the master do
file is always partisan-gaps.do
. An ado/
folder stores some of the custom Stata programs used in the scripts. The makefile
in the scripts/Stata/
provides a recipe to make the Stata output.
Structure of scripts/Stata/
folder
Collapse/expand
.
├── ado
│ ├── setup.ado
│ ├── storespecs.ado
│ ├── tictoc.ado
│ └── txt2macro.ado
├── mturk
│ ├── balance-tests.do
│ ├── barplot.do
│ ├── confidence-scoring-barplots.do
│ ├── confidence-scoring-reg-tables.do
│ ├── fig-partisan-gap-imc-24k-greaterthan7.do
│ ├── fig-partisan-gap-imc-24k.do
│ ├── fig-partisan-gap-ips-24k.do
│ ├── fig-partisan-gap-mc-24k.do
│ ├── fig-partisan-gap.do
│ ├── preamble.do
│ └── reg-table.do
├── mturk_hk
│ ├── barplots.do
│ ├── fig-partisan-gap.do
│ └── reg_table.do
├── survey-exp
│ ├── deficit-barplots.do
│ ├── preamble.do
│ ├── reg-table.do
│ └── unemp-barplots.do
├── tx-lyceum
│ ├── preamble.do
│ ├── reg-table.do
│ └── unemp-barplot.do
├── Makefile
├── partisan-gaps-log.txt
├── partisan-gaps.do
├── README.md
└── stata-requirements.txt
The scripts/Stata/partisan-gaps.do
do file is the master do
file to generate the tables and figures. In addition to (i) reproducing the key tables and figures, the partisan-gaps.do
master file also (ii) takes care of handling requirements using the Stata SSC packages enumerated in the stata-requirements.txt
file and the setup.ado
file, (iii) times the runtime of the script, and (iv) log the output to the partisan-gaps-log.txt
log file.
To make
the Stata output, cd
to scripts/Stata/
and type make all
. The path to the Stata executable is defined in the STATA_PATH
variable in the makefile
. Change the path as required. Alternatively, run partisan-gaps.do
from Stata to generate all output. The path to the project is defined in local rootdir D:/partisan-gaps
in the preamble. Change this as required. Making all the Stata output should take not much longer than a couple of minutes.
Python, via Jupyter notebooks, is used only to produce the balance of covariates tests for Study 1 (MTurk sample 1) and to inspect data. These are in scripts/py/
. The makefile
in the path runs both notebooks and outputs the balance tests figures with make all
(relies on the runpynb
and the forestplot
utilities). Making the Python output should take only a minute or so.
The total time to make
all output should take only a few minutes.
Most of the code uses R and Stata. Stata code was tested using Stata 13 and Stata 17. Python code is used sparingly from Jupyter notebooks. These can be run from the command line using the runpynb
utility (without initiating Jupyter notebooks JupyterLab). The manuscript is compiled in LaTeX
and from makefiles
using latexmk
. Some recipes are provided for convenience in the makefiles
using GNU Make. Makefiles come with quick help by typing make
or make help
.
Lucas Shen, Gaurav Sood, and Daniel Weitzel
- soodoku/nireland — Replication Data And Scripts for How Can You Think That?: Deliberation and the Learning of Opposing Arguments
- soodoku/party_time — Replication Data and Scripts for Affect, Not Ideology: A Social Identity Perspective on Polarization
- soodoku/pcomp
- soodoku/partisan_gap
- soodoku/partisan_head