Panel data treatment effects with multiple treatments

I have a fairly large balanced panel dataset ($$N$$ = 1000 and $$T$$ = 200) that I want to estimate a treatment effect for. My first thought was a difference-in-difference (DID) framework on this, but I'm unsure how to proceed because the treatments come and go repeatedly throughout the sample, and last for multiple periods. For example:

$$\begin{array}{ccc} \text{N} & \text{T} & \text{treatment} \\ \hline 1 & 1 & 0 \\ 1 & 2 & 1 \\ 1 & 3 & 1 \\ 1 & 4 & 0 \\ 1 & 5 & 1 \\ 1 & 6 & 1 \\ 1 & 7 & 0 \\ \hline 2 & 1 & 0 \\ 2 & 2 & 0 \\ 2 & 3 & 0 \\ 2 & 4 & 0 \\ 2 & 5 & 1 \\ 2 & 6 & 1 \\ 2 & 7 & 0 \\ \hline 3 & 1 & 0 \\ 3 & 2 & 0 \\ 3 & 3 & 0 \\ 3 & 4 & 0 \\ 3 & 5 & 0 \\ 3 & 6 & 0 \\ 3 & 7 & 0 \\ \end{array}$$

My treatments range from 4 to 6 periods long and occur at the same time across all $$N$$'s, with about 20% of the population being treated in each of the three rounds. I also have a good theoretical justification for the treatment selections being exogenous to the outcome.

I was looking at this answer, and other examples of panel data DID, but I don't have a clear pre-post split - I have repeated pre-during-post splits. In fact what I'm actually interested in is the effect during treatment, not the effect after. That is to say, I expect a return to normal after the treatment ends. Is DID the right framework for this?

• Welcome! Does three “rounds” mean three phases of treatment? If so, are these three completely different treatments? Your intuition about coding the treatment dummy is correct as I see it. Do the groups trends move in tandem prior to treatment? I know this is difficult to visualize with multiple groups and multiple start times, but it’s good to start thinking about the assumptions you’re making under this approach. Commented Apr 4, 2020 at 5:43

My first thought was a difference-in-difference (DID) framework on this, but I'm unsure how to proceed because the treatments come and go repeatedly throughout the sample, and last for multiple periods.

The visual is helpful. You're well within the realm of the 'generalized' difference-in-differences framework. Your "treatment" does not need to start and end at precisely the same time for all treated units/entities, nor is it required to remain "in effect" once the treatment begins for any particular unit. If coded properly, your treatment dummy should 'switch on' if any unit is in your treatment group and it enters into a post-treatment period. If treatment is rescinded for a previously treated unit/entity, then your treatment dummy should 'switch off' for that particular unit/entity. I am hesitant to use the term “treatment group” because, for the purposes of your study, your treatment indicator does not demarcate a specific treatment group. Rather, it is simply a discrete indicator indexing treated units and only during those periods when treatment is in effect. If your treatment indicator meets this criteria, then I would proceed with the 'generalized' approach. Other posts (see here, for example) often don’t perceive this as a difference-in-differences model, noting that there are "no interactions” present. But this is not true. Due to the complexity of your study, we must define the interaction term in a different way.

To help with your intuition, and others reading this, I will show you why your treatment variable is analogous to the one we observe in the 'classical' case where all units move into the treatment condition at the same time. The data frame below assumes the same structure, and shows 3 units/entities $$n$$ observed across 7 times periods $$t$$. Treatment starts at the fifth time period for all treated units (i.e., $$n = 2$$ and $$n = 3$$) and stays in effect for the duration of the panel. See the data frame below which shows the 'classical' difference-in-differences setup:

$$\begin{array}{ccc} \text{N} & \text{T} & \text{Treat} & \text{Post} & \text{Policy} \\ \hline 1 & 1 & 0 & 0 & 0 \\ 1 & 2 & 0 & 0 & 0 \\ 1 & 3 & 0 & 0 & 0 \\ 1 & 4 & 0 & 0 & 0 \\ 1 & 5 & 0 & 1 & 0 \\ 1 & 6 & 0 & 1 & 0 \\ 1 & 7 & 0 & 1 & 0 \\ \hline 2 & 1 & 1 & 0 & 0 \\ 2 & 2 & 1 & 0 & 0 \\ 2 & 3 & 1 & 0 & 0 \\ 2 & 4 & 1 & 0 & 0 \\ 2 & 5 & 1 & 1 & 1 \\ 2 & 6 & 1 & 1 & 1 \\ 2 & 7 & 1 & 1 & 1 \\ \hline 3 & 1 & 1 & 0 & 0 \\ 3 & 2 & 1 & 0 & 0 \\ 3 & 3 & 1 & 0 & 0 \\ 3 & 4 & 1 & 0 & 0 \\ 3 & 5 & 1 & 1 & 1 \\ 3 & 6 & 1 & 1 & 1 \\ 3 & 7 & 1 & 1 & 1 \\ \end{array}$$

The variable $$\text{Treat}$$ is dummy equal to 1 if the unit is in the treatment group, 0 otherwise. To be specific, $$\text{Treat}$$ equals 1 in all times periods for treated units/entities; it is time-invariant. The variable $$\text{Post}$$ changes over time but exhibits the same pattern within all units. It is equal to 1 in time period 5 onward in both treatment and control groups. It should be clear that $$\text{Treat} \times \text{Post} = \text{Policy}$$. Put simply, $$\text{Policy}$$ is the product of $$\text{Treat}$$ and $$\text{Post}$$. But what is the policy variable? Well, it 'turns on' (i.e., switches from 0 to 1) if it is in the treatment group and in the post-treatment period. In essence, this is what an interaction term is. In practice, you do not have to instantiate the $$\text{Policy}$$ variable manually. All you have to do is interact $$\text{Treat}$$ and $$\text{Post}$$ using software and the heavy lifting is done for you. I still think it's useful to actually see the column vector that is produced when we multiply the two main effects. Once we move to more complex scenarios, though, we should code this dummy explicitly.

The 'generalized' difference-in-differences framework is still an interaction model. Take your study, for instance, which involves multiple intermittent exposure phases, affecting multiple groups. The binary treatment variable (i.e., $$\text{Treatment}$$) can accommodate these irregular exposure patterns. In fact, it can take on any arbitrary pattern. It should be clear how the "interaction" is implicit in the coding of the treatment dummy: it is equal to 1 if it is a treated unit and in a post-treatment period. The post-treatment epoch does not have to be standardized across all units, nor does it need to remain 'turned on' once treatment commences.

To estimate a coefficient on your treatment variable, simply regress your outcome on a full series of $$N-1$$ unit effects (i.e., firm, entity, county, state, country, etc.), a full series of $$T-1$$ time effects (i.e., day, week, month, year, etc.), and your binary treatment variable. In your setting, it is unnecessary to include main effects for $$\text{Treat}$$ and $$\text{Post}$$ in your model; they are redundant. You can think of the unit and time fixed effects in the 'generalized' case as replacing $$\text{Treat}$$ and $$\text{Post}$$ in the 'classical' case, respectively. Let's look at each main effect, in turn, and see why we can drop them from the analysis in your setting.

Below is a another data frame with $$\text{Treat}$$ and $$\text{Post}$$, as before. Appended to the right are unit effects (i.e., dummies for each unit) and time effects (i.e., dummies for all time periods). I already stated that incorporating the variable $$\text{Treat}$$ into a model with staggered/irregular exposure patterns is unnecessary; it is time-constant and would be collinear with the unit effects. The redundancy is clear if we look at the pattern of the 0's and 1's. Note: $$\text{Treat} = N_2 + N_3$$. $$\text{Post}$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 & 2 & 1 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 3 & 3 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 3 & 4 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 3 & 5 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 3 & 6 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 3 & 7 & 1 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array}$$

Trying to substitute any other derivative of $$\text{Post}$$ into your model is not advisable. You might have thought: what is "post-treatment" for the "non-adopter" units? I hope it is clear that the "post" period is not standardized in your setting; it varies across treated units/entities! Thus, $$\text{Treat} \times \text{Post}$$ won't work in your setting.

Now let's substitute your original policy variable (i.e., $$\text{Treatment}$$) into the data frame, removing $$\text{Treat}$$ and $$\text{Post}$$, which are redundant. The variable $$\text{Treatment}$$ is estimable; it varies over time and across units. While no explicit multiplication is required to estimate your equation, the interaction term is implicit in the coding of the your treatment variable, as indicated below:

$$\begin{array}{ccc} \text{N} & \text{T} & \text{Treatment} & N_1 & N_2 & N_3 & T_1 & T_2 & T_3 & T_4 & T_5 & T_6 & T_7 \\ \hline 1 & 1 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 1 & 2 & 1 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 1 & 3 & 1 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 1 & 4 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 1 & 5 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 1 & 6 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 1 & 7 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \hline 2 & 1 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 2 & 2 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 2 & 3 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 2 & 4 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 2 & 5 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 2 & 6 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 2 & 7 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \hline 3 & 1 & 0 & 0 & 0 & 1 & 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 3 & 2 & 0 & 0 & 0 & 1 & 0 & 1 & 0 & 0 & 0 & 0 & 0 \\ 3 & 3 & 0 & 0 & 0 & 1 & 0 & 0 & 1 & 0 & 0 & 0 & 0 \\ 3 & 4 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 1 & 0 & 0 & 0 \\ 3 & 5 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 1 & 0 & 0 \\ 3 & 6 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 1 & 0 \\ 3 & 7 & 0 & 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 1 \\ \end{array}$$

Similar to the $$\text{Policy}$$ variable in the first data frame, $$\text{Treatment}$$ is equal to 1 if a unit is treated and in a post-treatment period, 0 otherwise. Put differently, your policy dummy 'turns on' in any 'unit-time' combination where these two conditions are present. Any "non-adopter" unit (e.g., $$n = 3$$) should be coded 0 in all time periods. You can think of the "never-receivers" as your baseline history of never receiving treatment. Again, the treatment dummy is allowed to take on irregular patterns. This estimator can be viewed as a weighted average of all possible two-group/two-period difference-in-differences estimators that can be constructed from the panel. See this post for more information on this.

In fact what I'm actually interested in is the effect during treatment, not the effect after. That is to say, I expect a return to normal after the treatment ends. Is DID the right framework for this?

If you expect a return to normalcy in the 'after' periods then you can certainly proceed with the 'generalized' difference-in-differences framework outlined above. This is actually good news in your setting, especially if the time interval between treatments is relatively close together. In the foregoing example, treatment 'turns off' (i.e., switches from 1 back to 0) for unit 1 in period $$t = 4$$. Concurrently, period $$t = 4$$ for unit 1 also serves as a counterfactual for unit 2. Moreover, unit 1's 'off' period is also its pre-period before the second treatment phase. If effects grow or fade substantially over time in the withdrawal periods then they could potentially offset pre-trends before a subsequent iteration of treatment.

If you suspect any strong lasting effects after treatment concludes then you could investigate this by including a 'lagged' version of your treatment variable onto the right-hand side of your model. I should also note, a model like this assumes constant effects while the treatment is in place. Is this reasonable in your setting? Maybe treatment is more dynamic than static? I can't answer this question for you, but it is something to consider.

In sum, if you're only interested in the actual policy periods, then leave your treatment dummy as is; your "post-treatment" periods denote your "during" periods. This language may seem unnatural, but the term "post-treatment" is assumed to represent the treatment phase. This is also referred to as a "static" treatment effect. You're not imposing any time-varying treatment structure.

A major hurdle to overcome is demonstrating the plausibility of common trends for units with multiple treatment histories. In a 2020 paper authored by me (see here), I used the 'generalized' approach to investigate the intermittent exposure of precincts to a crime policy. Each treatment phase was implemented across multiple years for a different subset of jurisdictions. To visually show a stability in the group trends, I plotted the intertemporal evolution of various crime trends before each intervention, using all non-participating jurisdictions as a counterfactual. This is similar to you juxtaposing, separately, the evolution of the group trends before $$t = 2$$ and $$t = 5$$. If all treated units become exposed to treatment at the same time and they each have sufficient pre-treatment data, then this should be fairly easy to demonstrate visually.

I should conclude by noting that new R packages are being developed to help deal with arbitrary 'on' and 'off' periods of treatment. See the remarks on page 12 of this manuscript.