<p>When you include country fixed effects <span class="math-container">$\alpha_i$</span> in your model you include a dummy variable for each country.</p>
<p>However, you cannot have a dummy variable for each <span class="math-container">$i$</span>, and still identify the coefficient <span class="math-container">$\beta_2$</span> on the variable <span class="math-container">$X_{2i}$</span> that only varies across <span class="math-container">$i$</span>. The coefficient <span class="math-container">$\beta_2$</span> on <span class="math-container">$X_{2i}$</span> can only be identified by cross-section variation - the variation across countries - because it has no time variation. However, all that variation is captured by the fixed effects <span class="math-container">$\alpha_i$</span>.</p>
<p>It is easy to see this. Consider the fact that for each <span class="math-container">$i$</span> you can simply set <span class="math-container">$\lambda_i=\beta_2X_{i2} + \alpha_i$</span> then the model becomes</p>
<p><span class="math-container">$Y_{i,t} = \lambda_i + \gamma_t + \beta_1\cdot X_{1,i,t} + \beta_3 \cdot X_{3,i,t} + \epsilon_{i,t},$</span></p>
<p>the model you want to estimate is indistinguishable from a model with another value of the fixed effects but without <span class="math-container">$\beta_2X_{i2}$</span>.</p>

CC BY-SA 4.0
2024-07-01T03:59:59.373Z
Jesper: Nice answer. I can see that $X_{2,i}$ doesn't vary over time but how can you tell that it doesn't vary within country so for a given $i$. ? In other words, isn't it possible that there are multiple observations of $X_{2,i}$ for a given $i$ because there are multiple observations of $Y_{i,t}$ for a given $i$ and given $t$. Maybe not but how do you know that ? Thanks.
mark leeds
CC BY-SA 4.0
2024-07-01T11:19:22.317Z
If there is variation for a single country across time the notation is wrong and $X_{2i}$ should be $X_{2it}$. Obviously, then there is time-variation and the coefficient is identified. If there are multiple observations for given $i$ and $t$ for example by subregions of a country I would still say the notation is wrong and should be $Y_{itc}$ and $X_{2ic}$ where $c$ is region. It is much more likely that the person has a country-panel data set (especially because if the situation you mention were the case R would not kick the variable due to perfect multicollinearity)
Jesper Hybel
CC BY-SA 4.0
2024-07-01T11:21:05.557Z
So I know because (1) I assume people write what they mean and (2) R drops due to collinearity which is inconsistent with the option you suggest.
Jesper Hybel
CC BY-SA 4.0
2024-07-01T15:47:06.890Z
The notation is not wrong if there are multiple observations in a country given $i$ and $t$. The $c$ subscript that you introduce is not necessary. But, given the message about collinearity, I would tend to think that there are not multiple observations also. So, your answer is most likely correct.
mark leeds
CC BY-SA 4.0
2024-07-01T17:43:37.587Z
Indexation is functional notation. $X_{2i}$ is used to indicate that given $i$ there is one and one value for the variable $X_2$ so yes it is wrong if you assume that there is more than one value given the country (example: https://math.stackexchange.com/questions/3704059/are-indexed-symbols-just-evaluated-functions)
Jesper Hybel
CC BY-SA 4.0
2024-07-02T05:14:39.403Z
I don't have time to read and understand what you linked to but thanks for it. When I have a lot of time, I'll check it out. It looks deep.   I was talking about more from an R call standpoint. but I'm also not familiar with feols which may require different notation from say a call to lm ? lm relies on the standard formula grammar from S+ but feols could be different. In the lm call, if you conditioned on country and year, then you wouldn't need a region variable. There could be multiple observations for country and year and things would just work.
mark leeds
CC BY-SA 4.0
2024-05-29T17:02:15.257Z
2024-05-29T18:18:54.063Z
2024-05-29T18:18:54.063Z
Jesper Hybel
<p>sorry if this is a basic question (I'm new to econometrics). I have the following regression model:</p>
<p><span class="math-container">$Y_{i,t} = \alpha_i + \gamma_t + \beta_1\cdot X_{1,i,t} + \beta_2 \cdot X_{2,i} + \beta_3 \cdot X_{3,i,t} + \epsilon_{i,t}$</span></p>
<p>where ( i ) symbolizes countries and ( t ) symbolizes time in years. <span class="math-container">$X_1$</span>, <span class="math-container">$X_2$</span> and <span class="math-container">$X_3$</span> are my independent variables.</p>
<p>I want to calculate the coefficients of this regression when <span class="math-container">$X_2$</span> changes between different countries, but not over time. The current model I'm running in R drops my <span class="math-container">$X_2$</span> variable due to collinearity, and I think it is because <span class="math-container">$X_2$</span> doesn't change over time.</p>
<p>This is my regression formula:
<code>fit_fe &lt;- feols(Donation_per_pop ~ Type_opt  + percentage_catholics + GDP | Country + Year , data=data_clean_na, se=vcov_cluster())</code></p>
<p>How can I properly include <span class="math-container">$X_2$</span> (percentage_catholics) in my TWFE regression model without it being dropped due to collinearity?</p>
<p>Thanks</p>

<econometrics><applied-econometrics><r><fixed-effects>
Variable dropped for collinearity in feols package in R (TWFE)
user308036
# Variable dropped for collinearity in feols package in R (TWFE)

(Asked by: username_0 on 2024-05-28)

sorry if this is a basic question (I'm new to econometrics). I have the following regression model:

$Y\_{i,t} = \alpha\_i + \gamma\_t + \beta\_1\cdot X\_{1,i,t} + \beta\_2 \cdot X\_{2,i} + \beta\_3 \cdot X\_{3,i,t} + \epsilon\_{i,t}$

where ( i ) symbolizes countries and ( t ) symbolizes time in years. $X\_1$, $X\_2$ and $X\_3$ are my independent variables.

I want to calculate the coefficients of this regression when $X\_2$ changes between different countries, but not over time. The current model I'm running in R drops my $X\_2$ variable due to collinearity, and I think it is because $X\_2$ doesn't change over time.

This is my regression formula:
`fit_fe <- feols(Donation_per_pop ~ Type_opt + percentage_catholics + GDP | Country + Year , data=data_clean_na, se=vcov_cluster())`

How can I properly include $X\_2$ (percentage\_catholics) in my TWFE regression model without it being dropped due to collinearity?

Thanks

**Tags:** econometrics, applied-econometrics, r, fixed-effects

---

## 1 answers

### Answer by username_1 on 2024-05-29. Score: 2 | Accepted answer

When you include country fixed effects $\alpha\_i$ in your model you include a dummy variable for each country.

However, you cannot have a dummy variable for each $i$, and still identify the coefficient $\beta\_2$ on the variable $X\_{2i}$ that only varies across $i$. The coefficient $\beta\_2$ on $X\_{2i}$ can only be identified by cross-section variation - the variation across countries - because it has no time variation. However, all that variation is captured by the fixed effects $\alpha\_i$.

It is easy to see this. Consider the fact that for each $i$ you can simply set $\lambda\_i=\beta\_2X\_{i2} + \alpha\_i$ then the model becomes

$Y\_{i,t} = \lambda\_i + \gamma\_t + \beta\_1\cdot X\_{1,i,t} + \beta\_3 \cdot X\_{3,i,t} + \epsilon\_{i,t},$

the model you want to estimate is indistinguishable from a model with another value of the fixed effects but without $\beta\_2X\_{i2}$.

> **Comments:**
> **username_2**: Jesper: Nice answer. I can see that $X_{2,i}$ doesn't vary over time but how can you tell that it doesn't vary within country so for a given $i$. ? In other words, isn't it possible that there are multiple observations of $X_{2,i}$ for a given $i$ because there are multiple observations of $Y_{i,t}$ for a given $i$ and given $t$. Maybe not but how do you know that ? Thanks.  
> **username_1**: If there is variation for a single country across time the notation is wrong and $X_{2i}$ should be $X_{2it}$. Obviously, then there is time-variation and the coefficient is identified. If there are multiple observations for given $i$ and $t$ for example by subregions of a country I would still say the notation is wrong and should be $Y_{itc}$ and $X_{2ic}$ where $c$ is region. It is much more likely that the person has a country-panel data set (especially because if the situation you mention were the case R would not kick the variable due to perfect multicollinearity)  
> **username_1**: So I know because (1) I assume people write what they mean and (2) R drops due to collinearity which is inconsistent with the option you suggest.  
> **username_2**: The notation is not wrong if there are multiple observations in a country given $i$ and $t$. The $c$ subscript that you introduce is not necessary. But, given the message about collinearity, I would tend to think that there are not multiple observations also. So, your answer is most likely correct.  
> **username_1**: Indexation is functional notation. $X_{2i}$ is used to indicate that given $i$ there is one and one value for the variable $X_2$ so yes it is wrong if you assume that there is more than one value given the country (example: https://math.stackexchange.com/questions/3704059/are-indexed-symbols-just-evaluated-functions)  
> **username_2**: I don't have time to read and understand what you linked to but thanks for it. When I have a lot of time, I'll check it out. It looks deep.   I was talking about more from an R call standpoint. but I'm also not familiar with feols which may require different notation from say a call to lm ? lm relies on the standard formula grammar from S+ but feols could be different. In the lm call, if you conditioned on country and year, then you wouldn't need a region variable. There could be multiple observations for country and year and things would just work.  

---

