*! version 1.0.0 21oct2019

tstf -- Intervention time-series models

Syntax

tstf
depvar
[if] [in]
[, options ]

Model
arima(#p,#d,#q) specify ARIMA(p,d,q) model for dependent variable

sarima(#P,#D,#Q,#s) specify period-#s multiplicative seasonal ARIMA term

intdate(time_value) specify the intervention date in the units of time variable

pulse specify the pulse transfer function

decay specify the decay transfer function

step specify the step transfer function

smooth specify the smooth transfer function

Path
pathr(R_pathname) specifies a path name for invoking the R command

Reporting
level(#) set confidence level; default is level(95)

tabulate tabulate effect of the intervention

grdta graph observed, predicted, and counterfactual data

greffect graph the intervention effect

eform exponentiate the results presented in tabular and graphical forms

twoway_options specify the options to pass to the graph

Data must be tsset before using tstf; see [TS] tsset.

Description

tstf fits intervention time-series models. The command tstf is a wrapper for the
arimax package in
R. Therefore R needs to be installed.

Options

Model

intdate(time_value) specify the intervention date (an integer number) in the units of time variable.
It is a required option to create the transfer function.

pulse specify the pulse transfer function.
The effect of the intervention is given by _b[omega] at the intervention time point.

step specify the step transfer function.
The effect of the intervention is given by _b[omega] at any time time point following the intervention.

decay specify the decay transfer function.
The effect of the intervention is given by _b[omega]*_b[delta]^k evaluated at k units of time after intervention.

smooth specify the smooth transfer function.
The effect of the intervention is given by _b[omega]*(1-(_b[delta])^(k+1))/(1-_b[delta]) evaluated at k units of time after intervention.

arima(#p,#d,#q) is
shorthand notation for specifying models with ARMA disturbances. The
dependent variable is differenced
#d times, 1 through #p lags of autocorrelations
and 1 through #q lags of moving averages are included in the model.
The default is (0,0,0).

sarima(#P,#D,#Q,#s) is a shorthand notation for specifying
the multiplicative seasonal components of models with ARMA disturbances.
The dependent variable is lag-#s
seasonally differenced #D times, and 1 through #P seasonal lags
of autoregressive terms and 1 through #Q seasonal lags of
moving-average terms are included in the model.
The default is (0,0,0,0).

Path

pathr(R_pathname) specifies the path name for invoking the R command.
The default path for a Mac is set to "/usr/local/bin/R".
The R_pathname can also be set by defining a global macro Rterm_path
(See rsource, Technical note).
The R code is available after running tstf command by typing viewsource tstf_to_r.R

Reporting

level(#); see
[R] estimation options.

Examples

* Read time-series data on the "Effect of tobacco control policies on the Swedish Smoking Quitline" BMJ Open

use http://www.stats4life.se/data/quitline, clear
tsset time, monthly

* Evaluation of the effect of the EU Directive on May 2016

* Interrupted time-series analysis using a Poisson regression model (`"do "`c(sysdir_plus)'/t/SNTQ_poisson.do"':click to run)

* Intervention time-series model

`"tstf lograte if inrange(time, 625, 691), smooth int(676) arima(1,1,1) sarima(1,0,0,12) tabulate grdata eform ytitle("Calling rates per 100,000 smokers") xlabel(625(6)691, angle(45)) xmtick(625(1)691) name(figure2a, replace)"'
`"tstf lograte if inrange(time, 625, 691), smooth int(676) arima(1,1,1) sarima(1,0,0,12) greffect eform ytitle("Rate Ratio") xlabel(625(6)691, angle(45)) xmtick(625(1)691) name(figure2b, replace)"'

* Evaluation of the effect of a campaign on passive smoking on Jan 2001

`"tstf lograte if inrange(time, 468, 511), smooth int(492) arima(2,1,0) sarima(0,0,0,12) tabulate grdata eform ytitle("Calling rates per 100,000 smokers") xlabel(468(6)511, angle(45)) xmtick(468(1)511) name(figure3a, replace)"'
`"tstf lograte if inrange(time, 468, 511), smooth int(492) arima(2,1,0) sarima(0,0,0,12) greffect eform ytitle("Rate Ratio") xlabel(468(6)511, angle(45)) xmtick(468(1)511) name(figure3b, replace) "'

* Evaluation of the effect of larger text warnings on Sept 2002

`"tstf lograte if inrange(time, 492, 544), smooth int(512) arima(2,1,0) sarima(1,0,0,12) tabulate grdata eform ytitle("Calling rates per 100,000 smokers") xlabel(492(6)544, angle(45)) xmtick(492(1)544) name(figure4a, replace) "'
`"tstf lograte if inrange(time, 492, 544), smooth int(512) arima(2,1,0) sarima(1,0,0,12) greffect eform ytitle("Rate Ratio") xlabel(492(6)544, angle(45)) xmtick(492(1)544) name(figure4b, replace) "'

* Evaluation of the effect of smoking free restaurants on Jan 2005

`"tstf lograte if inrange(time, 512, 587), smooth int(545) arima(1,0,0) sarima(0,1,1,12) tabulate grdata eform ytitle("Calling rates per 100,000 smokers") xlabel(512(6)587, angle(45)) xmtick(512(1)587) name(figure5a, replace) "'
`"tstf lograte if inrange(time, 512, 587), smooth int(545) arima(1,0,0) sarima(0,1,1,12) greffect eform ytitle("Rate Ratio") xlabel(512(6)587, angle(45)) xmtick(512(1)587) name(figure5b, replace) "'

* Evaluation of the effect of a Tax increase on Jan 2012

drop if time == 624 
`"tstf lograte if inrange(time, 588, 659), smooth int(624) arima(0,1,1) sarima(1,0,0,12) tabulate grdata eform ytitle("Calling rates per 100,000 smokers") xlabel(588(6)659, angle(45)) xmtick(588(1)659) name(figure6a, replace)"'
`"tstf lograte if inrange(time, 588, 659), smooth int(624) arima(0,1,1) sarima(1,0,0,12) greffect eform ytitle("Rate Ratio") xlabel(588(6)659, angle(45)) xmtick(588(1)659) name(figure6b, replace) "'

References

Zhou X, Crippa A, Danielsson AK, Galanti R, Orsini N (2019). Effect of tobacco control policies on the Swedish Smoking Quitline using intervention time series analysis. BMJ Open.

Box GEP, Tiao GC (1975). Intervention analysis with applications to economic and environmental problems. Journal of the American Statistical Association,
70(349), 70–79.

Authors

Nicola Orsini & Xing-Wu Zhou
Biostatistics Team
Department of Public Health Sciences, Karolinska Institutet
Stockholm, Sweden