<p>When you control for not just year fixed effects but instead year-region or year-industry it adds flexibility.</p>
<p>The year fixed effects controls in a flexible manner for the time-trend and is more flexible - less restrictive - than for example assuming that the time trend is for example linear <span class="math-container">$a \cdot t$</span>, second order polynomial <span class="math-container">$at + bt^2$</span>, exponential <span class="math-container">$exp(at)$</span> ect.</p>
<p>Nevertheless, year fixed effects are still restrictive compared to year-region or year-industry because the assume that the time trend is the same for all regions or for all industries instead of allowing different regions to follow different trends or different industries.</p>
<p>Consider for example this plot here</p>
<p><a href="https://i.sstatic.net/jA86J.jpg" rel="noreferrer"><img src="https://i.sstatic.net/jA86J.jpg" alt="enter image description here" /></a></p>
<p>and assume that it show the average wage of women (red) and the average wage of men (black) over time.</p>
<p>We then conclude that the gender wage-gap is closing. However, someone then points out this is not really the case because although female workers on average over time get the same as male workers this is simply because female workers have changed from predominantly working in the low-wage industry to be working in the high-wage industry.</p>
<p>Offcourse you are sharp and you run a regression controlling for industry</p>
<p><span class="math-container">$$\log y_{it} = \beta_0 + \alpha \cdot \text{male}_{it} + \lambda \cdot  \text{industry}_{it} + \delta_t + \epsilon_{it}$$</span></p>
<p>which is a good idea and for the simulated data used to generate the plot above you then get an estimate <span class="math-container">$\hat \alpha = 3.05$</span> clearly showing that male workers are given more in wage than female workers.</p>
<p>However, the true <span class="math-container">$\alpha$</span> is actually even larger and equal to <span class="math-container">$4$</span> so you are still underestimating the degree to which female workers are discriminated on the labor market.</p>
<p>In this example this happens because:</p>
<p><strong>Over time the wage in the high wage sector increases faster than the wage in the low wage sector. So while women over time changed to the high wage sector you are undercontrolling for the sector effect because the early year with a small difference between the sectors bias the sector effect downwards.</strong></p>
<p>In this case what you should have been doing to get an unbiased estimate was to run the regression</p>
<p><span class="math-container">$$\log y_{it} = \beta_0 + \alpha \cdot \text{male}_{it}  + \lambda_{st} + \epsilon_{it}$$</span></p>
<p>where <span class="math-container">$\lambda_{st}$</span> is the sector-time fixed effect.</p>
<p>You can simulate this example in R using the following code</p>
<pre><code>library(data.table)
library(lfe)
N1 &lt;- 1000
N2 &lt;- 1000
N &lt;- N1+N2
T &lt;- 10
b0 &lt;- 1

# a1 is the true gender effect
a1 &lt;- 4

gender &lt;- rep(c(rep(0,N1),rep(1,N2)),T)
a2 &lt;- rep(1:T * 2,N)
dt &lt;- data.table(id=rep(1:N,each=T),time=rep(1:T,N),gender=gender)
setkey(dt,time,gender)  
industry &lt;- c()
for (t in 1:T)
    {
        temp1 &lt;- sample(c(0,1),N1,replace=TRUE,prob=c(0.5,t/T))
        temp2 &lt;- sample(c(0,1),N1,replace=TRUE,prob=c(0.5,0.5))
        industry &lt;- c(industry,temp1,temp2)
    }
dt<span class="math-container">$industry &lt;- industry
setkey(dt,id,time)
dt$</span>log_y &lt;- b0 + a1*dt<span class="math-container">$gender + a2*dt$</span>industry + 0.3*dt<span class="math-container">$time + rnorm(N*T)
foo &lt;- dt[,.(m_wage=mean(log_y)),by=.(time,gender)]
plot(1:T,foo[gender==0,]$</span>m_wage,ylim=c(0,20),col=&quot;red&quot;,type=&quot;l&quot;)
points(1:T,foo[gender==1,]$m_wage,type=&quot;l&quot;)

dt<span class="math-container">$i_time &lt;- interaction(dt$</span>time,dt$industry)
# Regression with industry dummy

summary(felm(log_y ~ gender+industry|time,data=dt))
#          Estimate Std. Error t value Pr(&gt;|t|)    
# gender    3.05645    0.04164   73.41   &lt;2e-16 ***
# industry 11.13346    0.04215  264.12   &lt;2e-16 ***

# Regression with industry time fixed effects
summary(felm(log_y ~ gender |i_time,data=dt))

#        Estimate Std. Error t value Pr(&gt;|t|)    
# gender  4.00873    0.01443   277.7   &lt;2e-16 ***


savePlot(&quot;male_female.jpg&quot;,type=&quot;jpg&quot;)
</code></pre>

CC BY-SA 4.0
2021-05-15T23:20:38.057Z
Thank you for your clear explanation, I am using SAS so I am wondering if there is any SAS code available for this example. Thank you.
Phil Nguyen
CC BY-SA 4.0
2021-05-16T05:39:46.457Z
You are welcome. Unfortunately SAS i dont know. There is also an accept button you can press if you find this answered your question.
Jesper Hybel
CC BY-SA 4.0
2021-05-16T06:01:23.097Z
I am curious about one point: where λst is the sector-time fixed effect. So at that time, can you please help me to clarify what exactly λst stand for ? Thanks.
Phil Nguyen
CC BY-SA 4.0
2021-05-16T10:55:15.750Z
I can try. But I think you should make this follow up question in a seperate post. But $\lambda_{st}$ is short hand notation of $\sum_s \lambda_{st} 1[(i,t) \in s]$ where $1[(i,t) \in s]$ is indicator of individual $i$ working in sector $s$ at time $t$. So it is just a factor variable with levels being sector-time groups. I ignore the dummy variable trap. But this may not necessarily clean up any confusion you are having.
Jesper Hybel
CC BY-SA 4.0
2021-05-17T04:47:58.073Z
Thank you for your clear explanation. I raise another question here cited your answer as mentioned, I am wondering if you can have a look on that. https://quant.stackexchange.com/questions/64055/what-can-we-explain-while-adding-regionyear-fixed-effects-the-sign-flip
Phil Nguyen
CC BY-SA 4.0
2021-05-15T05:21:24.717Z
2021-05-15T05:21:24.717Z
Jesper Hybel
<p>Normally, we control for firm and year fixed effects, but in some case I saw people control for the  firm along with yearxindustry or firm and yearxregion fixed effects.
Could you please hint me why they need to do so?</p>

<regression><international-economics><fixed-effects>
Why we need to control for the interation of year and industry fixed effects?
Phil Nguyen
# Why we need to control for the interation of year and industry fixed effects?

(Asked by: username_0 on 2021-05-15)

Normally, we control for firm and year fixed effects, but in some case I saw people control for the firm along with yearxindustry or firm and yearxregion fixed effects.
Could you please hint me why they need to do so?

**Tags:** regression, international-economics, fixed-effects

---

## 1 answers

### Answer by username_1 on 2021-05-15. Score: 8 | Accepted answer

When you control for not just year fixed effects but instead year-region or year-industry it adds flexibility.
The year fixed effects controls in a flexible manner for the time-trend and is more flexible - less restrictive - than for example assuming that the time trend is for example linear $a \cdot t$, second order polynomial $at + bt^2$, exponential $exp(at)$ ect.
Nevertheless, year fixed effects are still restrictive compared to year-region or year-industry because the assume that the time trend is the same for all regions or for all industries instead of allowing different regions to follow different trends or different industries.
Consider for example this plot here

and assume that it show the average wage of women (red) and the average wage of men (black) over time.
We then conclude that the gender wage-gap is closing. However, someone then points out this is not really the case because although female workers on average over time get the same as male workers this is simply because female workers have changed from predominantly working in the low-wage industry to be working in the high-wage industry.
Offcourse you are sharp and you run a regression controlling for industry
$$\log y_{it} = \beta_0 + \alpha \cdot \text{male}_{it} + \lambda \cdot  \text{industry}_{it} + \delta_t + \epsilon_{it}$$
which is a good idea and for the simulated data used to generate the plot above you then get an estimate $\hat \alpha = 3.05$ clearly showing that male workers are given more in wage than female workers.
However, the true $\alpha$ is actually even larger and equal to $4$ so you are still underestimating the degree to which female workers are discriminated on the labor market.
In this example this happens because:
Over time the wage in the high wage sector increases faster than the wage in the low wage sector. So while women over time changed to the high wage sector you are undercontrolling for the sector effect because the early year with a small difference between the sectors bias the sector effect downwards.
In this case what you should have been doing to get an unbiased estimate was to run the regression
$$\log y_{it} = \beta_0 + \alpha \cdot \text{male}_{it}  + \lambda_{st} + \epsilon_{it}$$
where $\lambda_{st}$ is the sector-time fixed effect.
You can simulate this example in R using the following code
library(data.table)
library(lfe)
N1 <- 1000
N2 <- 1000
N <- N1+N2
T <- 10
b0 <- 1

# a1 is the true gender effect
a1 <- 4

gender <- rep(c(rep(0,N1),rep(1,N2)),T)
a2 <- rep(1:T * 2,N)
dt <- data.table(id=rep(1:N,each=T),time=rep(1:T,N),gender=gender)
setkey(dt,time,gender)  
industry <- c()
for (t in 1:T)
    {
        temp1 <- sample(c(0,1),N1,replace=TRUE,prob=c(0.5,t/T))
        temp2 <- sample(c(0,1),N1,replace=TRUE,prob=c(0.5,0.5))
        industry <- c(industry,temp1,temp2)
    }
dt$industry <- industry
setkey(dt,id,time)
dt$log_y <- b0 + a1*dt$gender + a2*dt$industry + 0.3*dt$time + rnorm(N*T)
foo <- dt[,.(m_wage=mean(log_y)),by=.(time,gender)]
plot(1:T,foo[gender==0,]$m_wage,ylim=c(0,20),col="red",type="l")
points(1:T,foo[gender==1,]$m_wage,type="l")

dt$i_time <- interaction(dt$time,dt$industry)
# Regression with industry dummy

summary(felm(log_y ~ gender+industry|time,data=dt))
#          Estimate Std. Error t value Pr(>|t|)    
# gender    3.05645    0.04164   73.41   <2e-16 ***
# industry 11.13346    0.04215  264.12   <2e-16 ***

# Regression with industry time fixed effects
summary(felm(log_y ~ gender |i_time,data=dt))

#        Estimate Std. Error t value Pr(>|t|)    
# gender  4.00873    0.01443   277.7   <2e-16 ***


savePlot("male_female.jpg",type="jpg")

> **Comments:**
> **username_0**: Thank you for your clear explanation, I am using SAS so I am wondering if there is any SAS code available for this example. Thank you.  
> **username_1**: You are welcome. Unfortunately SAS i dont know. There is also an accept button you can press if you find this answered your question.  
> **username_0**: I am curious about one point: where λst is the sector-time fixed effect. So at that time, can you please help me to clarify what exactly λst stand for ? Thanks.  
> **username_1**: I can try. But I think you should make this follow up question in a seperate post. But $\lambda_{st}$ is short hand notation of $\sum_s \lambda_{st} 1[(i,t) \in s]$ where $1[(i,t) \in s]$ is indicator of individual $i$ working in sector $s$ at time $t$. So it is just a factor variable with levels being sector-time groups. I ignore the dummy variable trap. But this may not necessarily clean up any confusion you are having.  
> **username_0**: Thank you for your clear explanation. I raise another question here cited your answer as mentioned, I am wondering if you can have a look on that. https://quant.stackexchange.com/questions/64055/what-can-we-explain-while-adding-regionyear-fixed-effects-the-sign-flip  

---

