Back

its2s: a Python package for two-stage interrupted time series analysis using machine learning

Wilner, L.; Casey, J. A.; Mooney, S. J.; Do, V.; Ma, Y.; Benmarhnia, T.; Dey, A. K.

2026-07-06 epidemiology
10.64898/2026.07.02.26357175 medRxiv
Show abstract

When randomized controlled trials are infeasible, researchers may leverage natural experiments for causal inference. Interrupted time-series (ITS) designs compare observed post-event trends to counterfactual predictions from pre-event data. Two-stage ITS designs use flexible models to generate optimized counterfactual predictions in the first stage, then estimate intervention effects by comparing observed to predicted outcomes in the second stage. Fitting high-dimensional versions of these models is challenging, requiring systematic infrastructure to ensure rigor and reproducibility. In response, we developed its2s, an open-source Python package implementing the two-stage ITS design with machine learning. its2s allows users to specify an intervention date and training/testing periods, select among built-in model architectures (e.g., Prophet-XGBoost, NeuralProphet), and generate confidence intervals via moving block bootstrap, preserving temporal autocorrelation in residuals. its2s layers defaults, configuration files, and runtime overrides to support workflows ranging from rapid default implementations to highly tailored analyses. We validated its2s using two case studies: a simulation with a 12% policy effect, recovering the true effect as 11.77%, and an analysis of the 2021 Pacific Northwest heat dome, finding 53% excess injury mortality over the following three weeks. its2s provides a flexible, reproducible framework for ITS-based quasi-experimental research, lowering barriers to rigorous machine learning-based counterfactual modeling.

Matching journals

The top 4 journals account for 50% of the predicted probability mass.

1
BMC Medical Research Methodology
47 papers in training set
Top 0.1%
18.8%
2
American Journal of Epidemiology
67 papers in training set
Top 0.1%
18.8%
3
PLOS ONE
5266 papers in training set
Top 18%
9.9%
4
eLife
5828 papers in training set
Top 16%
6.8%
50% of probability mass above
5
Nature Communications
5641 papers in training set
Top 32%
4.1%
6
PLOS Computational Biology
1863 papers in training set
Top 9%
3.6%
7
Statistics in Medicine
40 papers in training set
Top 0.2%
3.3%
8
Bioinformatics
1204 papers in training set
Top 5%
3.3%
9
International Journal of Epidemiology
88 papers in training set
Top 0.8%
1.8%
10
PeerJ
308 papers in training set
Top 5%
1.8%
11
PLOS Biology
486 papers in training set
Top 4%
1.8%
12
PLOS Global Public Health
344 papers in training set
Top 6%
1.7%
13
Proceedings of the National Academy of Sciences
2444 papers in training set
Top 28%
1.7%
14
Scientific Reports
3612 papers in training set
Top 61%
1.4%
15
Patterns
78 papers in training set
Top 2%
1.1%
16
GigaScience
212 papers in training set
Top 3%
1.1%
17
Epidemiology
32 papers in training set
Top 0.4%
1.1%
18
Clinical Trials
11 papers in training set
Top 0.3%
1.0%
19
Medical Decision Making
12 papers in training set
Top 0.3%
1.0%
20
Epidemics
116 papers in training set
Top 2%
0.9%
21
Trials
29 papers in training set
Top 1.0%
0.9%
22
BMC Public Health
158 papers in training set
Top 6%
0.6%
23
Environmental Health Perspectives
17 papers in training set
Top 0.4%
0.6%
24
Scientific Data
209 papers in training set
Top 3%
0.6%
25
BMC Research Notes
33 papers in training set
Top 1%
0.6%