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
-
In
replicate.R
, change the working directory path on line 9. -
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()
-
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 intests/data
. In that case, copy over all files intest/data
todata
. E.g. on OS X in terminal:cp tests/data/*.rda data/
-
We have included copies of the output in
tests
. The output indata
,figures
, andtables
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 fromreplicate.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 byR/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'svirtualenv
equivalenttests
: contains copies of output--intermediate files like estimated models, figures, and tables--against which to check results.