This repository contains the code for my paper The Optimal Allocation of Campaign Funds in House Elections. To run the analysis for the entire paper, first clone the directory,
git clone https://github.com/dincerti/optimal-house.git
Then, from the command line (terminal) run the script main.R
.
Rscript main.R
Make sure that all of the required packages have been installed. The script takes around 17 hours to run on my local machine. The code is slow because there are 20 separate Bayesian models that need to be estimated. The scripts containing these models are 04-do_hlm.R
, 06-do_dlmnat
, 07b-do_dlmcd_run
, and 07c-do_dlmcd_nprun
(06-do_dlmnat
is much faster than the others). Your machine must have at least four cores because the Bayesian models in 07b
and 07c
are run in parallel.