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?
Thank you in advance for your time.  
 A: Interrupted time series relies on correctly specifying the pre-intervention secular trends in order to detect departures-from-the-mean during the post-intervention era. An advantage of a balanced design is that a simple pre-mean adequately does that, in fact you don't even need to model time effects. Here balanced design means that ALL measures of time: relation to study start, age of participant, and calendar time are BALANCED between randomized intervention groups.
Your design uses a historical control. There are no participants without control. So the imbalance in intervention time is precisely what enables modeling to summarize pre-post effects with some precision.
In general, modeling time-series involves the AGE, PERIOD, and COHORT effects. All separate indices of time. There's a hefty literature on modeling so called "APC" effects.
In the panel dataset, adjust for baseline age, and if necessary baseline calendar year, and adjust for a time-varying measure of time on-study, and at the point of intervention, create an indicator variable and its interaction with time on-study.
