<p>Consider the following regression specification where, <span class="math-container">$t$</span> is time, <span class="math-container">$c$</span> is the firm, <span class="math-container">$y$</span> is an outcome and <span class="math-container">$x$</span> is a variable of interest.
<span class="math-container">$$
y_{c,t} = \alpha + \beta x_{c,t} + \varepsilon_{c,t}
$$</span></p>
<p>There are three types of omitted variables:</p>
<ol>
<li>Variables that vary with time but are the same across firms. Examples might be <em>weather conditions</em>,  <em>inflation rate</em>, <em>intrest rates</em>, <em>wages</em>, <em>demand shocks</em> (if firms operate on the same market) Let's call these <span class="math-container">$\gamma_t$</span> with only a subscript <span class="math-container">$t$</span> to indicate that they only vary over time.</li>
<li>Variables that vary over firms but are constant across time. Examples can be <em>firm location</em>, or <em>brand image</em>, <em>productivity</em> (if this remains constant over time), etc. Let's call these <span class="math-container">$\delta_c$</span></li>
<li>Variables that vary both over firms and over time. Examples might be <em>firm output</em> or <em>profits</em>. Let's call these <span class="math-container">$\chi_{c,t}$</span>.</li>
</ol>
<p>As all these variables are omitted, they enter the error term <span class="math-container">$\varepsilon_{c,t}$</span>, so:
<span class="math-container">$$
\varepsilon_{c,t} = \delta_c + \gamma_t + \chi_{c,t}
$$</span>
This decomposition can always be made by setting <span class="math-container">$\delta_c$</span> to be the expectation of <span class="math-container">$\varepsilon_{c,t}$</span> conditional on <span class="math-container">$c$</span> and <span class="math-container">$\gamma_t$</span> to be the expectation of <span class="math-container">$\varepsilon_{c,t}$</span> conditional on <span class="math-container">$t$</span>.  In particular, letting <span class="math-container">$\varepsilon_{.t}$</span> be the conditional mean of <span class="math-container">$\varepsilon$</span> on <span class="math-container">$t$</span>, and <span class="math-container">$\varepsilon_{c.}$</span> the conditional mean conditional on <span class="math-container">$c$</span>.  We have:</p>
<p><span class="math-container">$$
\varepsilon_{c,t} = \underset{\delta_c}{\underbrace{\varepsilon_{c.}}} + \underset{\gamma_t}{\underbrace{\varepsilon_{.t}}} + \underset{\chi_{c,t}}{\underbrace{(\varepsilon_{c,t} - \varepsilon_{c.} - \varepsilon_{.t})}}.
$$</span></p>
<p>In order to be able to get a good estimate of <span class="math-container">$\beta$</span> in the original regression you have to assume that <span class="math-container">$\varepsilon$</span> and <span class="math-container">$x$</span> are orthogonal:
<span class="math-container">$$
\mathbb{E}(\varepsilon x) = 0.
$$</span>
Using the decomposition above, this gives the requirement that:
<span class="math-container">$$
\mathbb{E}(\delta x) + \mathbb{E}(\gamma x) + \mathbb{E}(\chi x) = 0
$$</span></p>
<p>Now, you might be worried that this does not hold.</p>
<p>Fixed effects provides a manner to solve this as long as the orthogonality condition still holds for the 3rd type of omitted variables, i.e. as long as:
<span class="math-container">$$
\mathbb{E}(\chi x) = 0
$$</span>
Indeed, writing out the error term <span class="math-container">$\varepsilon_{c,t}$</span> in the regression we get:</p>
<p><span class="math-container">$$
y_{c,t} = \alpha + \delta_c + \gamma_t + \beta x_{c,t} + \chi_{c,t}.
$$</span>
The <span class="math-container">$\delta_c$</span> and <span class="math-container">$\gamma_t$</span> terms are captured by the firm and time fixed effects dummies, so we can identify as long as <span class="math-container">$x$</span> is orthogonal to <span class="math-container">$\chi$</span>.</p>
<p>Another way to see that <span class="math-container">$\beta$</span> is identified is to first take the mean of the regression over all firms, time periods and time and firms. This gives:
<span class="math-container">$$
\begin{align*}
&amp;y_{.t} = \alpha + \gamma_t + \beta x_{.,t},\\
&amp;y_{c.} = \alpha + \delta_c + \beta x_{c.},\\
&amp;y_{..} = \alpha + \beta x_{..}
\end{align*}
$$</span>
(Notice that <span class="math-container">$\chi_{c.} = \chi_{.t} = \chi_{..} = \delta_. = \gamma_. = 0$</span>  as, <span class="math-container">$\chi_{c,t} = \varepsilon_{c,t} - \varepsilon_{.t} - \varepsilon_{c.}$</span>)</p>
<p>Adding the last and subtracting the first two of the original regression gives:
<span class="math-container">$$
(y_{c,t} + y_{..} - y_{c.}- y_{.t}) = \beta(x_{c,t} + x_{..} - x_{c.} - x_{.t}) + \chi_{c,t}
$$</span>
So <span class="math-container">$\beta$</span> is identified by regressing <span class="math-container">$y_{c,t} + y_{..} - y_{c,.} - y_{.t}$</span> on <span class="math-container">$x_{c,t} + x_{..} - x_{c.} - x_{.t}$</span> .</p>
<blockquote>
<p><em>And when two-way fixed effects control for both time-variant and time-invariant variables, why researchers also include some independent variables? In short, is this redundant to add the other control variables when time-variant and time-invariant variables have been controlled by time and year fixed effects?</em></p>
</blockquote>
<p>Now it is important to add to the regression all other independent variables that fit into the 3rd category above, especially if you think they do not satisfy the orthogonality condition. For example, if you think <span class="math-container">$y$</span> is directly influenced by, say, firm profits (which is time and firm varying, so captured by <span class="math-container">$\chi$</span>)  and that <span class="math-container">$x$</span> is also correlated with firm profits, you will not be able to identify <span class="math-container">$\beta$</span> if you do not observe and control for firm profits.</p>

CC BY-SA 4.0
2021-06-05T10:26:07.103Z
A very comprehensive answer, thank you @tdm, can I ask some questions because I am not really good at math
Phil Nguyen
CC BY-SA 4.0
2021-06-05T10:28:38.117Z
(1) Wy you use the different order of period here $\varepsilon_{.t}$ and $\varepsilon_{c.}$, is there any purpose then ?
Phil Nguyen
CC BY-SA 4.0
2021-06-05T10:41:20.580Z
So, in short, whether the puspose of adding new variables is to try to satisfy this condition?    $$
\mathbb{E}(\chi x) = 0
$$
Phil Nguyen
CC BY-SA 4.0
2021-06-05T11:12:07.197Z
@Knowledge-chaser yes indeed. In fact, this is the basis of the entire [endogeneity literature](https://en.wikipedia.org/wiki/Endogeneity_(econometrics)).
tdm
CC BY-SA 4.0
2021-06-05T08:34:13.820Z
2021-06-05T08:34:13.820Z
tdm
<p>From what I know, these terms are very basic in econometrics but I still not yet fully got it. To me, year fixed effect is to control time-variant omitted variables and firm fixed effect is to control time-invariant omitted variables.</p>
<p><em>And when two-way fixed effects control for both time-variant and time-invariant variables, why researchers also include some independent variables? In short, is this redundant to add the other control variables when time-variant and time-invariant variables have been controlled by time and year fixed effects?</em></p>
<p><em>Apart from that, can I ask for some examples to clarify these context that I can understand &quot;<strong>firm fixed effect</strong>&quot; and &quot;<strong>year fixed effect</strong>&quot; better?</em></p>

CC BY-SA 4.0
2021-06-04T16:21:41.303Z
Fixed effects are dummies. They capture influences that affect all observations that have the same $n$ or (the same $t$ respectively) in the same way. Covariates are numbers, not dummies. It generally holds that $x_{it} \neq x_{jt}$ and $x_{it} \neq x_{is}$.
Grada Gukovic
CC BY-SA 4.0
2021-06-04T23:00:44.540Z
@GradaGukovic I am wondering if you can explicitly clarify more under an answer that all learners can benefit from? Thank you so much
Phil Nguyen
<econometrics><paneldata><fixed-effects>
Why we need to add firm and year relating independent variables in two-way fixed effect model?
Phil Nguyen
# Why we need to add firm and year relating independent variables in two-way fixed effect model?

(Asked by: username_0 on 2021-06-03)

From what I know, these terms are very basic in econometrics but I still not yet fully got it. To me, year fixed effect is to control time-variant omitted variables and firm fixed effect is to control time-invariant omitted variables.

*And when two-way fixed effects control for both time-variant and time-invariant variables, why researchers also include some independent variables? In short, is this redundant to add the other control variables when time-variant and time-invariant variables have been controlled by time and year fixed effects?*

*Apart from that, can I ask for some examples to clarify these context that I can understand "**firm fixed effect**" and "**year fixed effect**" better?*

**Tags:** econometrics, paneldata, fixed-effects

> **Comments:**
> **username_1**: Fixed effects are dummies. They capture influences that affect all observations that have the same $n$ or (the same $t$ respectively) in the same way. Covariates are numbers, not dummies. It generally holds that $x_{it} \neq x_{jt}$ and $x_{it} \neq x_{is}$.  
> **username_0**: @username_1 I am wondering if you can explicitly clarify more under an answer that all learners can benefit from? Thank you so much  

---

## 1 answers

### Answer by username_2 on 2021-06-05. Score: 5 | Accepted answer

Consider the following regression specification where, $t$ is time, $c$ is the firm, $y$ is an outcome and $x$ is a variable of interest.
$$
y\_{c,t} = \alpha + \beta x\_{c,t} + \varepsilon\_{c,t}
$$

There are three types of omitted variables:

1. Variables that vary with time but are the same across firms. Examples might be *weather conditions*, *inflation rate*, *intrest rates*, *wages*, *demand shocks* (if firms operate on the same market) Let's call these $\gamma\_t$ with only a subscript $t$ to indicate that they only vary over time.
2. Variables that vary over firms but are constant across time. Examples can be *firm location*, or *brand image*, *productivity* (if this remains constant over time), etc. Let's call these $\delta\_c$
3. Variables that vary both over firms and over time. Examples might be *firm output* or *profits*. Let's call these $\chi\_{c,t}$.

As all these variables are omitted, they enter the error term $\varepsilon\_{c,t}$, so:
$$
\varepsilon\_{c,t} = \delta\_c + \gamma\_t + \chi\_{c,t}
$$
This decomposition can always be made by setting $\delta\_c$ to be the expectation of $\varepsilon\_{c,t}$ conditional on $c$ and $\gamma\_t$ to be the expectation of $\varepsilon\_{c,t}$ conditional on $t$. In particular, letting $\varepsilon\_{.t}$ be the conditional mean of $\varepsilon$ on $t$, and $\varepsilon\_{c.}$ the conditional mean conditional on $c$. We have:

$$
\varepsilon\_{c,t} = \underset{\delta\_c}{\underbrace{\varepsilon\_{c.}}} + \underset{\gamma\_t}{\underbrace{\varepsilon\_{.t}}} + \underset{\chi\_{c,t}}{\underbrace{(\varepsilon\_{c,t} - \varepsilon\_{c.} - \varepsilon\_{.t})}}.
$$

In order to be able to get a good estimate of $\beta$ in the original regression you have to assume that $\varepsilon$ and $x$ are orthogonal:
$$
\mathbb{E}(\varepsilon x) = 0.
$$
Using the decomposition above, this gives the requirement that:
$$
\mathbb{E}(\delta x) + \mathbb{E}(\gamma x) + \mathbb{E}(\chi x) = 0
$$

Now, you might be worried that this does not hold.

Fixed effects provides a manner to solve this as long as the orthogonality condition still holds for the 3rd type of omitted variables, i.e. as long as:
$$
\mathbb{E}(\chi x) = 0
$$
Indeed, writing out the error term $\varepsilon\_{c,t}$ in the regression we get:

$$
y\_{c,t} = \alpha + \delta\_c + \gamma\_t + \beta x\_{c,t} + \chi\_{c,t}.
$$
The $\delta\_c$ and $\gamma\_t$ terms are captured by the firm and time fixed effects dummies, so we can identify as long as $x$ is orthogonal to $\chi$.

Another way to see that $\beta$ is identified is to first take the mean of the regression over all firms, time periods and time and firms. This gives:
$$
\begin{align\*}
&y\_{.t} = \alpha + \gamma\_t + \beta x\_{.,t},\\
&y\_{c.} = \alpha + \delta\_c + \beta x\_{c.},\\
&y\_{..} = \alpha + \beta x\_{..}
\end{align\*}
$$
(Notice that $\chi\_{c.} = \chi\_{.t} = \chi\_{..} = \delta\_. = \gamma\_. = 0$ as, $\chi\_{c,t} = \varepsilon\_{c,t} - \varepsilon\_{.t} - \varepsilon\_{c.}$)

Adding the last and subtracting the first two of the original regression gives:
$$
(y\_{c,t} + y\_{..} - y\_{c.}- y\_{.t}) = \beta(x\_{c,t} + x\_{..} - x\_{c.} - x\_{.t}) + \chi\_{c,t}
$$
So $\beta$ is identified by regressing $y\_{c,t} + y\_{..} - y\_{c,.} - y\_{.t}$ on $x\_{c,t} + x\_{..} - x\_{c.} - x\_{.t}$ .

> *And when two-way fixed effects control for both time-variant and time-invariant variables, why researchers also include some independent variables? In short, is this redundant to add the other control variables when time-variant and time-invariant variables have been controlled by time and year fixed effects?*

Now it is important to add to the regression all other independent variables that fit into the 3rd category above, especially if you think they do not satisfy the orthogonality condition. For example, if you think $y$ is directly influenced by, say, firm profits (which is time and firm varying, so captured by $\chi$) and that $x$ is also correlated with firm profits, you will not be able to identify $\beta$ if you do not observe and control for firm profits.

> **Comments:**
> **username_0**: A very comprehensive answer, thank you @username_2, can I ask some questions because I am not really good at math  
> **username_0**: (1) Wy you use the different order of period here $\varepsilon_{.t}$ and $\varepsilon_{c.}$, is there any purpose then ?  
> **username_0**: So, in short, whether the puspose of adding new variables is to try to satisfy this condition?    $$ \mathbb{E}(\chi x) = 0 $$  
> **username_2**: @Knowledge-chaser yes indeed. In fact, this is the basis of the entire [endogeneity literature](https://en.wikipedia.org/wiki/Endogeneity_(econometrics)).  

---

