Difference of $R^2$ between OLS with individual dummies to panel fixed effect model? Based on my understanding, panel fixed effect model is equivalent to OLS with individual dummies. However, when I ran the two models in R, the $R^2$ from the two models were quite different: 0.8 for OLS with individual dummies and 0.06 for fixed effect model.
Is it the case that in fixed effect model, the fixed effects (individual dummies) are excluded from the calculation of $R^2$?
 A: In essence, yes. The $R^2$ value given for fixed effects regressions is often called the "within $R^2$". If you use stata, the output will give overall, within, and between $R^2$. If you use the plm package in R, it just give the within $R^2$. The basic difference between the overall and within $R^2$ is that the within finds the total sum of squares on the demeaned outcome variable. Fixed effects regression demeans the y for each fixed entity.
For the fixed effects model, $$R^2 = \dfrac{SSR}{TSS_{demeaned \ y}} = \dfrac{\sum(y - \hat y)^2}{\sum([y_i - \bar y_i] - \overline {[y_i -  \bar y_i]})^2}$$
To demonstrate in R using the EmplUK data from plm:
    > library(plm)
    > data("EmplUK")
    > fixed <- plm(emp ~ wage + capital, data = EmplUK, index= 
         c("firm"), model = "within")
    > fixed.dum <- lm(emp ~ wage + capital + factor(firm) - 1, 
          data = EmplUK)
    > summary(fixed.dum)$r.squared[1] 
  summary(fixed)$r.squared[1] 
    [1] 0.9870826
          rsq 
    0.1635585 
    > 
    
    > #"Within" R2
    > SSR <- sum(fixed$residuals^2)
> demeaned_y <- EmplUK$emp - 
       tapply(EmplUK$emp, EmplUK$firm,mean)[EmplUK$firm]
> TSS_demeaned_y <- sum((demeaned_y-mean(demeaned_y))^2)
> within_R2 <- 1-(SSR/TSS_demeaned_y)
> c(summary(fixed)$r.squared[1], "rsq" = within_R2)
          rsq       rsq 
    0.1635585 0.1635585 

A: I have been looking for the three types of R-squared of the Fixed Effects model outputs in R as well.
Thanks to the help of @paqmo, I was able to manually calculate and reproduce lfe's full and proj R-squared using the model fit from the standard lm package. That said, I am quite certain that the full R-sq is straightforward, meaning R-sq of all pairs of predicted values and original values. At the same time, their proj R-squared is also identical to the so-called within R-squared (definitions from STATA), which is the default reported R-squared in the plm package.
After reading STATA manual Page 10 briefly, I think the full R-sq in lfe and overall R-sq in STATA are the same idea. I see some people said overall R-sq is a weighted average of within and between R-sq, but I did not see any supporting evidence for this statement. I only see that both overall and full R-sq are directly calculated from the pairs of predicted y and original y.
Below are my own calculations for full and proj R-sq.
    fe_lm_mod <- lm(formula = "y ~ x1 + x2 + entity - 1", 
       data = dataframe)
    ## Calculate prediction
    y_predict <- predict(fe_lm_mod, newdata = dataframe)
    y_original <- dataframe$y
    
    # Get the valid values indices
    notmiss <- which((!is.na(y_predict)) & (!is.na(y_original))) 

    # Residiual sum of squares
    SSres <- sum((y_original[notmiss] - y_predict[notmiss])**2)

    # Calculate full R2
    SStot_full <- sum((y_original[notmiss] - 
                    mean(y_original[notmiss]))**2)
    
    ### get the demean. The within finds the total sum of 
    ### squares on the demeaned outcome variable. 
    ### References
    # https://stats.stackexchange.com/questions/262246/difference-of-r2-between-ols-with-individual-dummies-to-panel-fixed-effect-mo
    demeaned_y <- y_original[notmiss] - 
      tapply(y_original[notmiss], dataframe$entity[notmiss], 
     mean)[dataframe$entity][notmiss]
    # Calculate within R2
    SStot_within <- sum((demeaned_y-mean(demeaned_y))^2)

    print(paste("calculated full R2", 1 - SSres/SStot_full))
    print(paste("calculated within R2", 1 - SSres/SStot_within))

For between R-sq, I think the plm package with model="between" may produce between R-sq, but I am not very sure. One can try to calculate it based on the STATA manual, like what I did for full and within R-sq.
So far I made a summary for the R-sq outputs (to be continued):

*

*lm R-sq: not good for Fixed Effects model, cannot reproduce

*lfe "full" R-sq: R-sq for all pairs predicted y and original y, may also be called as "overall" R-sq

*lfe "proj" R-sq: "within" R-sq: how much of the variation in the dependent variable within each entity group is captured by the model

*plm model="within" R-sq: same as 3.

*plm model="between" R-sq: "between" R-sq: how much of the variation in the dependent variable between each entity group is captured by the model

*plm model="pooling" R-sq: not good for Fixed Effects model. This is the standard OLS R-sq. It is not a Fixed Effects model R-sq.

