# Specifying a difference in differences model with multiple time periods

When I estimate a difference in differences model with two time periods, the equivalent regression model would be

a. $Y_{ist} = \alpha +\gamma_s*Treatment + \lambda d_t + \delta*(Treatment*d_t)+ \epsilon_{ist}$

• where $Treatment$ is a dummy which is equal to 1 if the observation is from the treatment group
• and $d$ is a dummy which is equal to 1 in the time period after the treatment occured

Thus the equation takes the following values.

• Control group, before treatment: $\alpha$
• Control group, after treatment: $\alpha +\lambda$
• Treatment group, before treatment: $\alpha +\gamma$
• Treatment group, after treatment: $\alpha+ \gamma+ \lambda+ \delta$

Hence, in a two period model the difference in differences estimate is $\delta$.

But what happens concerning $d_t$ if I have more than one pre and post treatment period? Do I still use a dummy that indicates whether a year is before or after the treatment?

Or do I add year dummies instead without specifying whether each year belong to the pre or post treatment period? Like this:

b. $Y_{ist} = \alpha +\gamma_s*Treatment + yeardummy + \delta*(Treatment*d_t)+ \epsilon_{ist}$

Or can I include both (i.e $yeardummy +\lambda d_t$)?

c. $Y_{ist} = \alpha +\gamma_s*Treatment + yeardummy + \lambda d_t + \delta*(Treatment*d_t)+ \epsilon_{ist}$

In conclusion, how do I specify a difference in differences model with multiple time periods (a,b or c)?

• You generally use model b. Notice that in model c, $d_t$ will be perfectly collinear with the year dummies, so that model can't be estimated. Jan 17 '14 at 12:28
• It would be great if you could explain why b is used generally. Maybe give some references, or just give a 2 sentence explanation. Jan 17 '14 at 12:51
• and in model b. could you add a continuous variable for year instead of dummies? How would the interpretation of the coefficients differ in those cases?
– user71597
Mar 20 '15 at 16:22

The typical way to estimate a difference in differences model with more than two time periods is your proposed solution b). Keeping your notation you would regress $$Y_{ist} = \alpha +\gamma_s (\text{Treatment}_s) + \lambda (\text{year dummy}_t) + \delta D_{st} + \epsilon_{ist}$$ where $D_t \equiv \text{Treatment}_s\cdot d_t$ is a dummy variable which equals one for treatment units $s$ in the post-treatment period ($d_t = 1$) and is zero otherwise. Note that this is a more general formulation of the difference in differences regression which allows for different timings of the treatment for different treated units.

As was pointed out correctly in the comments your proposed solution c) does not work out due to collinearity with the time dummies and the dummy for the post-treatment period. However, a slight variant of this turns out to be a robustness check. Let $\gamma_{s0}$ and $\gamma_{s1}$ be two sets of dummy variables for each control unit $s0$ and each treated unit $s1$, respectively, then interacting the dummies for the treated units with the time variable $t$ and regressing $$Y_{ist} = \gamma_{s0} + \gamma_{s1}t + \lambda (\text{year dummy}_t) + \delta D_{st} + \epsilon_{ist}$$ includes a unit specific time trend $\gamma_{s1}t$. When you include these unit specific time trends and the difference in differences coefficient $\delta$ does not change significantly you can be more confident about your results. Otherwise you might wonder whether your treatment effect has absorbed differences between treated units due to an underlying time trend (can happen when policies kick in at different points in time).

An example cited in Angrist and Pischke (2009) Mostly Harmless Econometrics is a labor market policy study by Besley and Burgess (2004). In their paper it happens that the inclusion of state-specific time trends kills the estimated treatment effect. Note though that for this robustness check you need more than 3 time periods.

• A follow up since I am trying to decide if implementing this with some administrative data is appropriate: Would you say a DD approach is more valid than a CITS design if there are only 4 time points (2 pre and 2 post) in a model? Also, if I have multiple cohorts within waves of data should these be examine separately or in a unified model? Thanks. Feb 24 '16 at 17:02
• @Andy: Can you pls explain, what you mean by s0, s1, and unit-specific time trend? Assuming I have two newspapers (WPT and NYT) and WPT is my treatement group, which of them would be s0 and s1? Apr 12 '18 at 20:49
• Am I right in thinking that this analysis compares the average pre and post treatment and does not account for secular trends? i.e. if d_t = 0 for all time periods before the switch point, and d_t = 1 for all time periods after, then this analysis is essentially the same as the two time periods one, except the average is taken of all the before/after time periods. Any time trends in the outcome before/after the treatment switch are ignored? I am trying to decide if a DiD model is correct for an analysis I am planning to carry out.
– AP30
Mar 11 '19 at 17:42

I would like to clarify something (and indirectly address a question in the comments). In particular, it concerns the use of unit-specific linear time trends. As a robustness check, it would appear you are only interacting dummies for treated units (i.e., $$\gamma_{1s}$$) with a continuous time trend. However, it is actually the case that you are interacting a full set of unit/state dummies (unit/state fixed effects) with a linear time trend variable.

Angrist and Pischke (2009) recommend this approach on page 238 in Mostly Harmless Econometrics. Differences in notation can cause confusion. Reproducing specification 5.2.7:

$$y_{ist} = \gamma_{0s} + \gamma_{1s} t + \lambda_{t} + \delta D_{st} + X^{'}_{ist}\beta + \varepsilon_{ist},$$

where $$\gamma_{0s}$$ is a state-specific intercept, in accordance with the $$s$$ subscript used in their book. You can view $$\gamma_{1s}$$ as the state-specific trend coefficient multiplying the time trend variable, $$t$$. Different papers use different notation. For example, Wolfers (2006) replicates a model incorporating state-specific linear time trends. Reproducing model (1):

$$y_{s,t} = \sum_{s} State_{s} + \sum_{t} Year_{t} + \sum_{s} State_{s}*Time_{t} + \delta D_{s,t} + \varepsilon_{s,t},$$

where the model includes state and year fixed effects (i.e., dummies for each state and year). The treatment variable $$D_{s,t}$$ is when state $$s$$ adopts a unilateral divorce regime in period $$t$$. Notice this specification interacts state dummies with a linear time trend (i.e., $$Time_{t}$$). This is yet another representation of state-specific linear time trends in your model specification.

Unit-specific linear time trends is also addressed nicely in the comments section here.

In sum, you want to interact all unit (group) dummies with a continuous time trend variable.

You can read the paper by Justin Wolfers (2006) for free here.