title: Different result using fixest and multiple fixed effects
body: <p>First of all, I have to apologize if my headline is misleading. I am not sure how to put it appropriately for my question.</p>
  <p>I am currently working on the fixed-effect model. My data looks like the following table, although it is not actual data due to the information privacy.</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>state</th>
  <th>district</th>
  <th>year</th>
  <th>grade</th>
  <th>Y</th>
  <th>X</th>
  <th>id</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2009</td>
  <td>3</td>
  <td>0.1</td>
  <td>0.5</td>
  <td>1001.3</td>
  </tr>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2010</td>
  <td>3</td>
  <td>0.8</td>
  <td>0.4</td>
  <td>1001.3</td>
  </tr>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2011</td>
  <td>3</td>
  <td>0.5</td>
  <td>0.7</td>
  <td>1001.3</td>
  </tr>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2009</td>
  <td>4</td>
  <td>1.5</td>
  <td>1.3</td>
  <td>1001.4</td>
  </tr>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2010</td>
  <td>4</td>
  <td>1.1</td>
  <td>0.7</td>
  <td>1001.4</td>
  </tr>
  <tr>
  <td>AK</td>
  <td>1001</td>
  <td>2011</td>
  <td>4</td>
  <td>2.1</td>
  <td>0.4</td>
  <td>1001.4</td>
  </tr>
  <tr>
  <td>...</td>
  <td>...</td>
  <td>...</td>
  <td>..</td>
  <td>..</td>
  <td>..</td>
  <td>...</td>
  </tr>
  <tr>
  <td>WY</td>
  <td>5606</td>
  <td>2011</td>
  <td>6</td>
  <td>4.2</td>
  <td>5.3</td>
  <td>5606.6</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I used the <code>fixest</code> package to run the fixed-effect model for this project. To get the unique observation in this dataset, I have to combine district, grade, and year. Note that I avoided using <code>plm</code> because there is no way to specify three fixed effects in the model unless you combine two identities (in my case, I generated id by combining district and grade). <code>fixest</code> seems to be able to solve this problem. <strong>However,</strong> I got different results when specifying three fixed effects (district, grade, and year) compared to two fixed effects (id and year). The following results and codes may clear up some confusion from my explanation.</p>
  <pre><code># Two fixed effects (id and year)
  df &lt;- transform(df, id = apply(df[c(&quot;district&quot;, &quot;grade&quot;)], 1, paste, collapse = &quot;.&quot;))
  fe = feols(y ~ x | id + year, df, se = &quot;standard&quot;)
  summary(fe)
  
  OLS estimation, Dep. Var.: y
  Observations: 499,112 
  Fixed-effects: id: 64,302,  year: 10
  Standard-errors: IID 
    Estimate Std. Error t value   Pr(&gt;|t|)    
  X 0.012672   0.003602 3.51804 0.00043478 ***
      ---
      Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
      RMSE: 0.589222     Adj. R2: 0.761891
                       Within R2: 2.846e-5
  
  ###########################################################################
  
  # Three fixed effects (district, grade, and year)
  fe = feols(y ~ x | district + grade + year, df, se = &quot;standard&quot;)
  summary(fe)
  
  OLS estimation, Dep. Var.: y
  Observations: 499,112 
  Fixed-effects: district: 11,097,  grade: 6,  year: 10
  Standard-errors: IID 
    Estimate Std. Error t value   Pr(&gt;|t|)    
  X 0.014593    0.00401 3.63866 0.00027408 ***
  ---
  Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
  RMSE: 0.702543     Adj. R2: 0.698399
                   Within R2: 2.713e-5
  </code></pre>
  <p><em><strong>Questions:</strong></em></p>
  <ol>
  <li>Why are the results different?</li>
  <li>This is an equation I plan to use;<a href="https://i.stack.imgur.com/4kuiR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4kuiR.png" alt="enter image description here" /></a>. I am not sure which model is associated with this specification. To my feeling, it could be the second one. But if it is the case, why do many websites recommend combining two identities and running normal <code>plm</code>.</li>
  </ol>
  <p>Thank you so much for reading my question. Any answers/ suggestions/ advice would be appreciated!</p>