# Resources for Interrupted time series analysis in R

I am fairly new to R. I have attempted to read up on time series analysis and have already finished

1. Shumway and Stoffer's Time series analysis and its applications 3rd Edition,
2. Hyndman's excellent Forecasting: principles and practice
3. Avril Coghlan's Using R for Time Series Analysis
4. A. Ian McLeod et al Time Series Analysis with R
5. Dr. Marcel Dettling's Applied Time Series Analysis

Edit: I'm not sure how to handle this but I found a usefull resource outside of Cross Validated. I wanted to include it here in case anyone stumbles upon this question.

Segmented regression analysis of interrupted time series studies in medication use research

I have a univariate time series of the number of items consumed (count data) measured daily for 7 years. An intervention was applied to the study population at roughly the middle of the time series. This intervention is not expected to produce an immediate effect and the timing of the onset of effect is essentially unknowable.

Using Hyndman's forecast package I have fitted an ARIMA model to the pre-intervention data using auto.arima(). But I am unsure of how to use this fit to answer whether there has been a statistically significant change in trend and quantify the amount.

# for simplification I will aggregate to monthly counts
# I can later generalize any teachings the community supplies
count <- c(2464, 2683, 2426, 2258, 1950, 1548, 1108,  991, 1616, 1809, 1688, 2168, 2226, 2379, 2211, 1925, 1998, 1740, 1305,  924, 1487, 1792, 1485, 1701, 1962, 2896, 2862, 2051, 1776, 1358, 1110,  939, 1446, 1550, 1809, 2370, 2401, 2641, 2301, 1902, 2056, 1798, 1198,  994, 1507, 1604, 1761, 2080, 2069, 2279, 2290, 1758, 1850, 1598, 1032,  916, 1428, 1708, 2067, 2626, 2194, 2046, 1905, 1712, 1672, 1473, 1052,  874, 1358, 1694, 1875, 2220, 2141, 2129, 1920, 1595, 1445, 1308, 1039,  828, 1724, 2045, 1715, 1840)
# for explanatory purposes
# month <- rep(month.name, 7)
# year <- 1999:2005
ts <- ts(count, start(1999, 1))
train_month <- window(ts, start=c(1999,1), end = c(2001,1))
require(forecast)
arima_train <- auto.arima(train_month)
fit_month <- Arima(train_month, order = c(2,0,0), seasonal = c(1,1,0), lambda = 0)
plot(forecast(fit_month, 36)); lines(ts, col="red")


Are there any resources specifically dealing with interrupted time series analysis in R? I have found this dealing with ITS in SPSS but I have not been able to translate this to R.

• Do you want to do inference on whether the intervention had a statistically significant effect, or do you want to model the intervention to obtain better forecasts? And could you possibly make the data available? – Stephan Kolassa Dec 2 '15 at 20:08
• @StephanKolassa Certainly! My aim is to do inference. I will provide dummy data in an Edit to better illustrate my point. – dais.johns Dec 2 '15 at 20:14
• @StephanKolassa Data provided to the best of my abilities. – dais.johns Dec 2 '15 at 20:35
• Previous research suggests the intervention affect to be on the scale of +/- 5% change. – dais.johns Dec 2 '15 at 20:37
• @StephanKolassa Provided actual usable data – dais.johns Dec 2 '15 at 22:51

This is known as change-point analysis. The R package changepoint can do this for you: see the documentation here (including references to the literature): http://www.lancs.ac.uk/~killick/Pub/KillickEckley2011.pdf