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)?
 A: 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: 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.
