Replication code for "Lessons from near real-time forecasting of irregular leadership changes", Journal of Peace Research
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
data
figures
packrat
tests
.Rprofile
.gitignore
README.md
replicate.R

README.md

Replication materials for:

Lessons from near real-time forecasting of irregular leadership changes

Journal of Peace Research, 2017

For questions contact the corresponding author Michael Ward, or Andreas Beger.

Citation:

Ward, Michael D. and Andreas Beger, 2017 (forthcoming), "Lessons from near real-time forecasting of irregular leadership changes", Journal of Peace Research.

@article{ward:beger:2017,
  Author = {Michael D. Ward and Andreas Beger},
  Journal = {Journal of Peace Research},
  Month = {tba},
  Number = {tba},
  Pages = {tba},
  Title = {Lessons from near Real-time Forecasting of Irregular Leadership Changes},
  Volume = {tba},
  Year = {2017}
}

Getting the code and data

The easiest way to get the replication code is to download a zip. Alternatively, you can clone the repository through the Github GUI client (OS X, Windows).

Running the replication

  1. Download or clone this repository.

  2. In replicate.R, change the working directory path on line 9.

  3. Setup R library dependencies. We use packrat for this, which will create a private R library containing the specific versions of the various R packages that we used during our latest replication. To setup the libraries, follow the steps that are also included in the replication script, i.e.:

    library("packrat")
    
    packrat::restore()
    packrat::status()
  4. Run through the remaining scripts sourced in the replication script. If you don't want to re-estimate all the models, we have saved all the intermediary files generated by the R/estimate-and-forecast.R script in tests/data. In that case, copy over all files in test/data to data. E.g. on OS X in terminal:

    cp tests/data/*.rda data/
  5. We have included copies of the output in tests. The output in data, figures, and tables that is generated by the replication script should match these results.

The code was developed over several versions of R. The latest we ran and checked results against was R 3.3.0 on OS X.

File notes

  • R: contains the main working scripts. Called from replicate.R as needed.
    • utilities: various minor functions used by the other scripts.
  • data: contains the source data from 2015-08, and will also later contain estimated models and other intermediate files generated by R/estimate-and-forecast.R that are used by other scripts.
    • W.gower.fix.rda: this is only needed for the Appendix. The 2015-08 version of the data inadvertently missed one of the Polity-based Gower spatial lags for the 1990's, which is something we fixed in a later version of the data. This is drop-in data that is needed to fix this for the Appendix lasso/random forest comparison; but it is not needed for the original forecasts.
  • packrat: R's virtualenv equivalent
  • tests: contains copies of output--intermediate files like estimated models, figures, and tables--against which to check results.