help itsa (SJ21-2: st0389_6)

Title

itsa -- Interrupted time-series analysis for single and multiple groups

Syntax

itsa depvar [indepvars] [if] [in] [weight],
trperiod(date)
[single treatid(#)
contid(numlist) prais lag(#)
figure[(twoway_options)]
lowess posttrend replace prefix(string)
[model_options]

indepvars may contain factor variables; see fvvarlist.
depvar and indepvars may contain time-series operators; see
tsvarlist. aweights are allowed with the newey option; see weight. See
[TS] newey postestimation and
[TS] prais postestimation for features available
after estimation.

A dataset for a single panel must be declared to be time-series data by using
tsset timevar. When the dataset contains multiple panels, a
strongly balanced panel dataset using tsset panelvar timevar
must be declared. See tsset.

Description

itsa estimates the effect of an intervention when the outcome variable
is ordered as a time series and a number of observations are available in both
preintervention and postintervention periods. The study design is generally
referred to as an interrupted time-series analysis (ITSA) because the
intervention is expected to interrupt the level or trend subsequent to its
introduction (Campbell and Stanley 1966; Glass, Willson, and Gottman 1975;
Shadish, Cook, and Campbell 2002).

itsa is a wrapper program for newey by default, which produces
Newey-West standard errors for coefficients estimated by ordinary
least-squares regression. It can optionally be a wrapper for prais,
which uses the generalized least-squares method to estimate the parameters in
a linear regression model in which the errors are assumed to follow a
first-order autoregressive process.

itsa estimates treatment effects for either a single treatment group
(with preintervention and postintervention observations) or a multiple-group
comparison (that is, the single treatment group is compared with one or more
control groups). Additionally, itsa can estimate treatment effects for
multiple treatment periods.

Options

trperiod(date) specifies the time period when the
intervention begins. The value(s) entered for time period(s) must be in the same
units as the panel time variable specified in tsset timevar; see
tsset. Dates should be specified using the respective
pseudofunction (see datetime), such as trperiod(2020)
for a four-digit year, trperiod(2019m11) for quarterly data or
trperiod(20jan2021) for daily data. Multiple periods may be specified,
separated by a semicolon, as trperiod(2019m6; 2019m11); trperiod() is
required.

single indicates that itsa will be used for a single-group
analysis. Conversely, omitting single indicates that itsa is for
a multiple-group comparison.

treatid(#) specifies the identifier of the single treated
unit under study when the dataset contains multiple panels. The value entered
must be in the same units as the panel variable specified in tsset
panelvar timevar; see tsset. When the dataset contains data for
only a single panel, treatid() must be omitted.

contid(numlist) specifies a list of identifiers to be used as
control units in the multiple-group analysis. The values entered must be in
the same units as the panel variable specified in tsset panelvar
timevar; see tsset. If contid() is not specified, all
nontreated units in the data will be used as controls.

prais specifies to fit a prais model. If prais is
not specified, itsa will use newey as the default model.

lag(#) specifies the maximum lag to be considered in the
autocorrelation structure when a newey model is chosen. If the user
specifies lag(0), the default, the output is the same as regress,
vce(robust). An error message will appear if both prais and
lag() are specified, because prais implements an AR(1) model by
design.

figure[(twoway_options)] produces
a line plot of the predicted depvar variable combined with a scatterplot
of the actual values of depvar over time. In a multiple-group analysis,
figure plots the average values of all controls used in the analysis
(more specifically, data for specified controls are collapsed and the monthly
observations are averaged). Specifying figure without options uses the
default graph settings.

lowess plots a lowess smoothed line of depvar on timevar.

posttrend produces posttreatment trend estimates using lincom,
for the specified model. In the case of a single-group ITSA, one estimate is
produced. In the case of a multiple-group ITSA, an estimate is produced for
the treatment group, the control group, and the difference. In the case of
multiple treatment periods, a separate table is produced for each treatment
period.

replace replaces variables created by itsa if they already exist.
If prefix() is specified, only variables created by itsa with the
same prefix will be replaced.

prefix(string) adds a prefix to the names of variables
created by itsa. Short prefixes are recommended.

model_options specify all available options for prais when the
prais option is chosen; otherwise, all available options for
newey other than lag() are specified.

Remarks

Regression (with methods to account for autocorrelation) is the most commonly
used modeling technique in interrupted time-series analyses. When there is
only one group under study (no comparison groups), the regression model
assumes the following form (Simonton 1977a, 1977b; Huitema and McKean 2000;
Linden and Adams 2011):

Y_t = Beta_0 + Beta_1(T) + Beta_2(X_t) + Beta_3(TX_t) (1)

Here Y_t is the aggregated outcome variable measured at each equally spaced
time point t, T is the time since the start of the study, X_t is a dummy
(indicator) variable representing the intervention (preintervention periods 0,
otherwise 1), and TX_t is an interaction term between X_t and a sequentially
numbered variable starting in the period immediately following the intervention.

In the case of a single-group study, Beta_0 represents the intercept or
starting level of the outcome variable. Beta_1 is the slope or trajectory of
the outcome variable until the introduction of the intervention. Beta_2
represents the change in the level of the outcome that occurs in the period
immediately following the introduction of the intervention (compared with the
counterfactual). Beta_3 represents the difference between preintervention and
postintervention slopes of the outcome. Thus we look for significant p-values
in Beta_2 to indicate an immediate treatment effect, or in Beta_3 to indicate
a treatment effect over time (Linden and Adams 2011). However, single-group
ITSA models may provide misleading results, so multiple-group ITSA models
should be implemented whenever possible (Linden 2017b and 2017c).

When one or more control groups are available for comparison, the regression
model in (1) is expanded to include four additional terms (Beta_4 to Beta_7)
(Simonton 1977a, 1977b; Linden and Adams 2011):

Y_t = Beta_0 + Beta_1(T) + Beta_2(X_t) + Beta_3(TX_t) +
Beta_4(Z) + Beta_5(ZT) + Beta_6(ZX_t) + Beta_7(ZTX_t) (2)

Here Z is a dummy variable to denote the cohort assignment (treatment or
control), and ZT, ZX_t, and ZTX_t are all interaction terms among previously
described variables. Now the coefficients Beta_0 to Beta_3 represent the
control group, and the coefficients Beta_4 to Beta_7 represent values of the
treatment group. More specifically, Beta_4 represents the difference in the
level (intercept) of the dependent variable between treatment and controls
prior to the intervention, Beta_5 represents the difference in the slope
(trend) of the dependent variable between treatment and controls prior to the
intervention, Beta_6 indicates the difference between treatment and control
groups in the level of the dependent variable immediately following
introduction of the intervention, and Beta_7 represents the difference between
treatment and control groups in the slope (trend) of the dependent variable
after initiation of the intervention compared with preintervention (akin to a
difference-in-differences of slopes).

The two parameters Beta_4 and Beta_5 play a particularly important role in
establishing whether the treatment and control groups are balanced on both the
level and the trajectory of the dependent variable in the preintervention
period. If these data were from a randomized controlled trial, we would
expect similar levels and slopes prior to the intervention. However, in an
observational study where equivalence between groups cannot be ensured, any
observed differences will likely raise concerns about the ability to draw
causal inferences about the relationship between the intervention and the
outcomes (Linden and Adams 2011). See Linden (2017a) for many
additional ITSA postestimation measures.

Examples

There are three general scenarios in which itsa can be implemented: 1) a
single-group ITSA using data with only the one panel, 2) a single-group ITSA
in data where there are other panels, and 3) a multiple-group ITSA. The
examples below are described accordingly, using data from Abadie, Diamond, and
Hainmueller (2010) and Linden and Adams (2011):

1) Single-group ITSA in data with only one panel

Load single panel data and declare the dataset as time series:

. use cigsales_single, clear

. tsset year

We specify a single-group ITSA and 1989 as the first year of the intervention,
plot the results, and produce a table of the posttreatment trend estimates.
We then run actest to test for autocorrelation over the past 12
periods. (See Linden and Yarnold [2016] for a comprehensive
discussion.)

. itsa cigsale, single trperiod(1989) lag(1) fig posttrend

. actest, lags(12)

2) Single-group ITSA in data with multiple panels

Load multiple-panel data and declare the dataset as panel:

. use cigsales, clear

. tsset state year

We specify a single-group ITSA with California (state number 3 in the study)
as the treatment group and 1989 as the first year of the intervention, plot
the results with an added lowess smoother, and produce a table of the posttreatment trend estimates.

. itsa cigsale, single treatid(3) trperiod(1989) lag(1) figure low posttrend

Same as above, but we specify prais to fit an AR(1) model. We
specify rhotype(tscorr), which bases p on the autocorrelation of the
residuals, and add robust standard errors.

. itsa cigsale, single treatid(3) trperiod(1989) figure posttrend replace prais rhotype(tscorr) vce(robust)

Here we specify two treatment periods, starting in 1982 and 1989 and specify
that xlabel() shows 5-year increments. We also add a lowess smoother to the graph.

. itsa cigsale, single treatid(3) trperiod(1982; 1989) lag(1) figure(xlabel(1970(5)2000)) low posttr replace

Here we limit the range of observations to the period 1975 to 1995.

. itsa cigsale if inrange(year, 1975, 1995), single treatid(3) trperiod(1982; 1989) lag(1) figure posttr replace

3) Multiple-group ITSA

We specify a multiple-group ITSA by omitting single and allowing all
other groups in the file to be used as control groups.

. itsa cigsale, treatid(3) trperiod(1989) lag(1) figure(xlabel(1970(5)2000)) posttrend replace

Same as above, but we indicate specific control groups to use in the
analysis. These matches were identified using itsamatch.

. itsa cigsale, treatid(3) trperiod(1989) contid(4 8 19) lag(1) replace figure(xlabel(1970(5)2000)) posttrend

Output table

itsa produces several variables, as defined under Remarks above.
Below is a cross reference to default names for those variables that appear in
the regression output tables (and used when posttrend is specified).
Variables starting with _z are added to the dataset only when a
multiple-group comparison is specified. (trperiod) is a suffix added to
certain variables indicating the start of the intervention period. This is
particularly helpful for differentiating between added variables when multiple
interventions are specified. If the user specifies a prefix(), it will
be applied to all variables generated by itsa.

Variable Description

_depvar dependent variable

_t time since start of study

_x(trperiod) dummy variable representing the intervention periods (preintervention periods 0, otherwise 1)

_x_t(trperiod) interaction between _x and a sequentially numbered variable starting in the period immediately following the intervention

_z dummy variable to denote the cohort assignment (treatment or control)

_z_x(trperiod) interaction of _z and _x

_z_x_t(trperiod) interaction of _z, _x, and _t

_s_depvar_pred predicted value generated after running itsa for a single group

_m_depvar_pred predicted value generated after running itsa for a multiple-group comparison

Acknowledgments

I owe a tremendous debt of gratitude to Nicholas J. Cox for his never-ending
support and patience with me while originally developing itsa. I would
also like to thank Steven J. Samuels for creating the posttrend option
and help with various other improvements to itsa. Federico Tedeschi
found an error in the multiple-group or multiple-intervention posttrend
estimation. Nicola Orsini correctly noted that _t should start at 0,
rather than 1.

References

Abadie, A., A. Diamond, and J. Hainmueller. 2010.
Synthetic control methods for comparative case studies: Estimating the
effect of California's tobacco control program.
Journal of the American Statistical Association
105: 493-505.

Campbell, D. T., and J. C. Stanley. 1966.
Experimental and Quasi-Experimental Designs for Research.
Chicago: Rand McNally.

Glass, G. V., V. L. Willson, and J. M. Gottman. 1975.
Design and Analysis of Time-Series Experiments.
Boulder, CO: Colorado Associated University Press.

Huitema, B. E., and J. W. McKean. 2000.
Design specification issues in time-series intervention models.
Educational and Psychological Measurement
60: 38-58.

Linden, A. 2015.
Conducting interrupted time series analysis for single and multiple group comparisons.
Stata Journal.
15: 480-500.

------. 2017a.
A comprehensive set of postestimation measures to enrich interrupted time-series analysis.
Stata Journal
17: 73-88.

------. 2017b.
Challenges to validity in single-group interrupted time series analysis.
Journal of Evaluation in Clinical Practice.
23: 413-418.

------. 2017c.
Persistent threats to validity in single-group interrupted time series analysis with a crossover design.
Journal of Evaluation in Clinical Practice.
23: 419-425.

Linden, A., and J. L. Adams. 2011.
Applying a propensity-score based weighting model to interrupted time
series data: Improving causal inference in program evaluation.
Journal of Evaluation in Clinical Practice
17: 1231-1238.

Linden, A., and P. R. Yarnold. 2016.
Using machine learning to identify structural breaks in single-group
interrupted time series designs.
Journal of Evaluation in Clinical Practice
22: 855-859.

Shadish, S. R., T. D. Cook, and D. T. Campbell. 2002.
Experimental and Quasi-Experimental Designs for Generalized Causal Inference.
Boston: Houghton Mifflin.

Simonton, D. K. 1977a.
Cross-sectional time-series experiments: Some suggested statistical analyses.
Psychological Bulletin
84: 489-502.

Simonton, D. K. 1977b. Erratum to Simonton. Psychological Bulletin
84: 1097.

Author

Ariel Linden

Linden Consulting Group, LLC

alinden@lindenconsulting.org

Also see

Article: Stata Journal, volume 21, number 2: st0389_6,

Stata Journal, volume 17, number 4: st0389_5,

Stata Journal, volume 17, number 2: st0389_4,

Stata Journal, volume 17, number 1: st0389_3,

Stata Journal, volume 16, number 3: st0389_2,

Stata Journal, volume 16, number 2: st0389_1,

Stata Journal, volume 15, number 2: st0389

Help: newey, prais, actest (if installed), itsamatch (if installed), itsaperm (if installed), xtitsa (if installed)