Skip to content

Stepshift

peder2911 edited this page Nov 2, 2021 · 3 revisions

Stepshift

ViEWS uses a bespoke modelling approach which involves shifting all independent variables in time, in order to train models that can predict future values of the dependent variable. This approach is described in more detail in Appendix A of Hegre et al. (2020).

Installation

The modelling technique is implemented in a python package called stepshift, which can be installed using pip:

pip install stepshift

Usage

Stepshift has a module called stepshift.views which contains a class called StepshiftedModels. This class wraps the stepshifting procedure, exposing a simple, Scikit-Learn-like (but not equivalent) API. The model takes three arguments: A scikit learn estimator, a list containing integers, which denotes the steps, and a string variable which is the name of the dependent variable:

from sklearn.linear_model import LogisticRegression
from stepshift.views import StepshiftedModels

mdl = StepshiftedModels(LogisticRegression(),[1,2,3,4,5,6,7,8],"outcome")

References

  • Hegre H, Bell C, Colaresi M, et al. ViEWS2020: Revising and evaluating the ViEWS political Violence Early-Warning System. Journal of Peace Research. 2021;58(3):599-611. doi:10.1177/0022343320962157

Clone this wiki locally