# Interrupted Time Series with varying intervention dates

I have ~400 time series with measurements of a response variable over the course of 48 weeks. An intervention occurred at week 24 in each time series. A simulated version is provided below:

set.seed(1234)

x <- 100
y <- 150
z <- 200

noise <- rnorm(48, mean = 100, sd = 10)

for(i in 2:length(noise)){

if(i < 25){
x[i] <- x[i-1] + rnorm(1, mean = 0, sd = 100)
y[i] <- y[i-1] + rnorm(1, mean = 0, sd = 100)
z[i] <- z[i-1] + rnorm(1, mean = 0, sd = 100)

}else{
x[i] <- x[i-1] + rnorm(1, mean = 0, sd = 100) + 10
y[i] <- y[i-1] + rnorm(1, mean = 0, sd = 100) + 10
z[i] <- z[i-1] + rnorm(1, mean = 0, sd = 100) + 10
}

}

df <- data.frame(ID = c(rep(1, 48), rep(2, 48), rep(3, 48)), Time = rep(1:48, 3), Response = c(x,y,z))
df$$Intervention <- df$$Time > 24



I have used a generalised least squares regression with an interaction term as below:

require(nlme)

glsfit <- gls(Response ~ Time + Intervention + Time:Intervention, data = df)



Although the intervention for each time series is the same, and I have an equal length of observations before and after the intervention for each series, the intervention itself was applied at different times for each participant. For example, one time series may cover the period between 2018-05-20 and 2019-04-21 while another may be between 2017-11-26 and 2018-10-28.

Are the results of this regression therefore invalid and, if so, is it possible to control for the fact that the intervention occurred at different times for each individual time series?