<p>The short answer is yes, you can control for any number of dimensions. However,  there are some caveats.</p>
<p>In terms of being able to estimate the model, you <em>need</em> at least one observation per cell. In your case, you need to have at least one observation for every firm<span class="math-container">$\times$</span>year<span class="math-container">$\times$</span>industry combination.</p>
<p>If you have only a single observation per cell, then you will have a perfect fit (<span class="math-container">$R^2 = 1$</span>) and your residual will be swallowed up by your fixed effects estimates. Your coefficient will then simply equal your corresponding <span class="math-container">$y$</span>-value.</p>
<p>In general, your fixed effects estimates will equal the average <span class="math-container">$y$</span> value over all observations in the given cell.</p>
<p>This means that if you want to have &quot;good&quot; estimates of your fixed effects coefficients, you need many observations per cell. To get consistent estimates, the number of observations per cell needs to go to infinity as the number of observations goes to infinity.</p>

CC BY-SA 4.0
2021-07-13T17:15:02.320Z
Not sure your 4th para is correct. It is not just the average y value, but the average y value  partialled out from other regressors/fixed effects
ChinG
CC BY-SA 4.0
2021-07-14T05:09:29.360Z
@ChinG I was under the impression that there were only fixed effects (no other regressors). If there are, you are indeed correct.
tdm
CC BY-SA 4.0
2021-07-13T09:36:11.220Z
2021-07-13T09:36:11.220Z
tdm
<p>We have a great discussion <a href="https://economics.stackexchange.com/questions/45765/have-you-ever-seen-any-paper-controlling-for-firm-industry-and-year-fixed-effe">here</a> about controlling for three dimensions (firm, year, and industry fixed effects)</p>
<p>A reasonable way to do so so far is controlling for <strong>firms fixed effect</strong> and <strong>industry * year</strong> fixed effect.</p>
<p>However, today my senior friend said that we can do three dimensions controlling in Stata by using</p>
<p><strong>reg y x i.firm. i.year i.industry</strong></p>
<p>I cannot check this code because my data is around 300,000 obs so STATA will create a super big matrix of coefficients.. I am wondering is it code right and how to convert it to <strong>reghdfe</strong> code?</p>

<econometrics>
Revisiting whether we can control for three dimensions or not?
Phil Nguyen
# Revisiting whether we can control for three dimensions or not?

(Asked by: username_0 on 2021-07-12)

We have a great discussion [here](https://economics.stackexchange.com/questions/45765/have-you-ever-seen-any-paper-controlling-for-firm-industry-and-year-fixed-effe) about controlling for three dimensions (firm, year, and industry fixed effects)

A reasonable way to do so so far is controlling for **firms fixed effect** and **industry \* year** fixed effect.

However, today my senior friend said that we can do three dimensions controlling in Stata by using

**reg y x i.firm. i.year i.industry**

I cannot check this code because my data is around 300,000 obs so STATA will create a super big matrix of coefficients.. I am wondering is it code right and how to convert it to **reghdfe** code?

**Tags:** econometrics


---

## 1 answers

### Answer by username_1 on 2021-07-13. Score: 2 | Accepted answer

The short answer is yes, you can control for any number of dimensions. However, there are some caveats.

In terms of being able to estimate the model, you *need* at least one observation per cell. In your case, you need to have at least one observation for every firm$\times$year$\times$industry combination.

If you have only a single observation per cell, then you will have a perfect fit ($R^2 = 1$) and your residual will be swallowed up by your fixed effects estimates. Your coefficient will then simply equal your corresponding $y$-value.

In general, your fixed effects estimates will equal the average $y$ value over all observations in the given cell.

This means that if you want to have "good" estimates of your fixed effects coefficients, you need many observations per cell. To get consistent estimates, the number of observations per cell needs to go to infinity as the number of observations goes to infinity.

> **Comments:**
> **username_2**: Not sure your 4th para is correct. It is not just the average y value, but the average y value  partialled out from other regressors/fixed effects  
> **username_1**: @username_2 I was under the impression that there were only fixed effects (no other regressors). If there are, you are indeed correct.  

---

