# Is it appropriate to use state or time fixed effects in a difference-in-differences model?

I am running a regression which analyzes the effects of a state level policy on crime rates in America. I am using the difference-in-differences estimator and I'm not sure whether I can still add fixed effects into the model. I have a couple of control variables as well but I do not know whether including state or time fixed effects would be appropriate when using the difference-in-differences estimator. Also, I am confused as to how to add these fixed effects and what fixed effects to use in Stata.

• Welcome. At what level is the policy? Is it a state level policy? – Thomas Bilach Jun 6 at 21:48
• Yes. It is state level – Debbie Jun 6 at 21:49
• FMHO, adding firm and year fixed effects should be a need when dealing with panel data. Regarding the second question, you can use xtset, or areg, or else. These code structure can be searched through the Help command – Knowledge-chaser Jun 6 at 21:51
• Thank you. It is a panel data. What examples of state fixed effects could I use? Geography? Size? and how would I present that in the data set. For instance i used dummy variables for the treatment. Would it be the same procedure for the state fixed effects? – Debbie Jun 6 at 21:54

I am using the difference-in-differences estimator and I'm not sure whether I can still add fixed effects into the model.

Of course you can.

If the policy is adopted by treated states at the same time then you can estimate your model more simply as the interaction of a treatment/control dummy with a pre-/post-policy indicator. However, it's rare to observe states adopt crime initiatives uniformly. Thus, the rest of my answer assumes the 'roll out' of the policy is staggered over time.

I have a couple of control variables as well but I do not know whether including state or time fixed effects would be appropriate when using the difference-in-differences estimator.

It's very appropriate.

And you must include state and time (e.g., month, quarter, year, etc.) fixed effects, in addition to your policy variable(s).

I am confused as to how to add these fixed effects and what fixed effects to use in Stata.

Well, this is a bit off-topic. It's a general programming question. Again, you must use unit and time fixed effects. For example, suppose you acquired state level auto theft rates across all 50 states over the last ten years. Simply regress the auto theft rate on state fixed effects, year fixed effects, and the policy indicator (i.e., 'turns on' if a state $$s$$ adopts and is in the years $$t$$ when the policy is actually in effect, 0 otherwise). Once you xtset your data, then the basic structure is as follows:

xtset state year
xtreg crime policy other_covariates i.year, fe cluster(state)


where crime is a crime measure of interest and policy is the dichotomous treatment variable. The other_covariates is standing in for any other time-varying covariates at the state level.

• Can you elaborate on why avoiding including fixed effects is problematic when the policy is adopted by a subset of treated states at the same time? – Dimitriy V. Masterov Jun 8 at 19:19
• Control variables are good as long they vary over time and are not affected by the policy itself or its anticipation. – Dimitriy V. Masterov Jun 8 at 19:23
• @DimitriyV.Masterov I don't make the claim it's problematic. Rather, I was suggesting that estimating fixed effects for state and year is redundant if states adopt uniformly and the OP is using the classical DiD estimator. I will update my response to make this a bit more clear. – Thomas Bilach Jun 8 at 20:22
• @DimitriyV.Masterov Say 5 treated states adopt a crime initiative in 2015. The post-treatment period is well-defined. The state fixed effects would absorb a treatment/control dummy. Similarly, the year fixed effects would absorb a pre-/post-policy indicator. It shouldn't affect the DiD coefficient, but the model has redundancies. Would you agree? – Thomas Bilach Jun 8 at 21:10
• I agree on the treated dummy, but I believe year FEs and the "policy on" coefficient are identified by the variation across states in treatment. There are some untreated states in post-2015 years and some treated, so you could have both with a policy dummy that is 1 in post-treatment for the treated and 0 elsewhere. – Dimitriy V. Masterov Jun 8 at 22:07