# Where is variation coming from regressions with continuous variables and state and time fixed effects?

Say first I am regressing $$Y_{st} = \beta X_{st} + U_s + \epsilon_{st}$$ where $$X$$ is continuous varying at the state time, $$U$$ are state fixed effects, and $$\epsilon$$ is the error term. If I understand correctly, this is a within state estimator, and I’m literally not comparing states, I’m looking at changes in $$X$$ around the state mean of $$x$$, and relating that to changes in $$Y$$ around the $$y$$ state mean, and then aggregating these effects across states to come up with an estimate (is this intuition correct?)

Now say I estimate the same equation but with time fixed effects. Now is it still accurate to call it a ‘within’ state estimator, since the time fixed effects now mean even states without any variation within state over time are being used to identify $$\beta$$? How exactly do I think of what comparisons I am making in the data in this set up?

Edit: just to clarify my question is about how $$\beta$$ is being identified- I.e. what comparisons in the data are being made to identify $$\beta$$ when you include both state and time fixed effects?

• Although the term "state" appears nine times in your question, I still can't figure out what it means--or whether it means anything. Could you explain?
– whuber
Commented Feb 28, 2020 at 16:52
• Sorry- I meant say running a regression where you have data on states (such as California) and time, but I guess state fixed effects just means group fixed effects, but I used state just to fix an example. I am basically wondering when you have group fixed effects and time fixed effects, what exactly are the comparisons being made in the data (I.e. comparing changes in states to changes in other states?) if you include both state and time fixed effects Commented Feb 28, 2020 at 17:07
• To clarify, you are seeking to understand the differences between “group” (i.e., state) and “time” fixed effects given your model? I assume you have panel data. Are you observing U.S. states across years? Commented Feb 28, 2020 at 17:11
• Not necessarily the difference. I want to know what variation we are using to identify B is both state and time fixed effects are included vs just state fixed effects. And yes to the. State panel data Commented Feb 28, 2020 at 17:13
• Does this question need the DID tag? Commented Feb 28, 2020 at 18:18

To begin, I assume you want to estimate the following model,

$$y_{st} = \delta x_{st} + \gamma_{s} + \lambda_{t} + u_{st},$$

where your outcome $$y_{st}$$ is regressed on a continuous policy variable $$x_{st}$$ and a series of state and time effects represented by $$\gamma_{s}$$ and $$\lambda_{t}$$, respectively. In most practical applications, you simply input dummies into the model for each state and time period.

If I understand correctly, this is a within state estimator, and I’m literally not comparing states, I’m looking at changes in X around the state mean of x, and relating that to changes in Y around the y state mean , and then aggregating these effects across states to come up with an estimate (is this intuition correct?)

To address the first part of your question, your intuition is correct, though I am not sure what you mean when you say you are not comparing states. Assume you estimate the foregoing model and omit time fixed effects. This is the standard 'one-way' unit (state) fixed effects estimator; it is also referred to as the within estimator, since you are restricting attention to within-state variation. This estimator uses the variation in $$y_{st}$$ and $$x_{st}$$ within each state to estimate the coefficient $$\delta$$.

We can achieve the same estimate of $$\delta$$ using deviations from time means. Think about what this is doing. Note the subscript on the averages:

$$(y_{st} - \bar{y}_{s}) = \delta(x_{st} - \bar{x}_{s}) + (u_{st} - \bar{u}_{s}),$$

which decrements each observation within a state from its time average. You correctly note that you now run a regression on the demeaned data. Analogously, the 'one-way' time fixed effects estimator does the following:

$$(y_{st} - \bar{y}_{t}) = \delta(x_{st} - \bar{x}_{t}) + (u_{st} - \bar{u}_{t}),$$

which subtracts the mean across units but within each time point. This eliminates the variables that vary over time but are fixed across states. Put differently, time fixed effects account for the impacts common to all units (states), but vary over time (e.g., years).

We can put this all together using a mean-centering approach to operationalize the fixed effects along each dimension. The following equation was reproduced from a working paper by Kropko and Rubinec (2018):

$$\hat{\delta}_{TW} = \frac{\sum_{s = 1}^{S}\sum_{t = 1}^{T}(y_{st} - \bar{y}_{s} - \bar{y}_{t} + \bar{y})(x_{st} - \bar{x}_{s} - \bar{x}_{t} + \bar{x})}{\sum_{s = 1}^{S}\sum_{t = 1}^{T}(x_{st} - \bar{x}_{s} - \bar{x}_{t} + \bar{x})^2}.$$

You may have seen this referenced as a 'two-way' fixed effects estimator. Note the subtraction of the mean along one dimension, then the subtraction of these differences along the other dimension. Covariates that are fixed across time are removed through subtraction of the time-means. Simultaneously, covariates that are fixed across states are removed through the subtraction of the state-means. Though somewhat confusing, the 'two-way' coefficients average the within-unit (state) and within-time slopes. I should also caution that this equation assumes balanced panels.

Now is it still accurate to call it a ‘within’ state estimator, since the time fixed effects now mean even states without any variation within state over time are being used to identify B?

Yes. This is a within-state estimator. In some applications, you may want to include both state and time fixed effects. Be mindful, this is context specific. Combining state and time fixed effects does two things: (1) accounts for factors that differ across states but are constant over time, and (2) controls for those unobservables that do change over time, but are constant across states.

In sum, I acknowledge that the interpretation of $$\hat{\delta}_{TW}$$ is not so straightforward. It is also worth noting that the foregoing paper was largely a treatise regarding the interpretive difficulties associated with these types of models!

I hope this helps! I will let someone else tender their opinion regarding the complexity of estimating fixed effects along the cross-sectional and longitudinal dimensions.

Another post that may address your concerns: Difference between one-way and two-way fixed effects, and their estimation.

• Thank you so much! Very helpful answer. Commented Feb 29, 2020 at 0:14
• No problem! I also noticed you included a DiD tag. You correctly note that the 'generalized' DiD equation is a 'two-way' fixed effects estimator. Several papers, most notably one by Andrew Goodman Bacon (2018) show that the 'generalized' DiD approach relying on variation in treatment timing can be decomposed into a weighted average of all possible two-group/two-period DiD estimators that can be constructed from the data. Though his paper is largely a treatise on the method using discretized treatments, it may still be of value to you. Commented Mar 30, 2020 at 23:01