$\begingroup$

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

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.