Panel Data – Difference of $R^2$ Between OLS with Individual Dummies and Panel Fixed Effect Model

fixed-effects-modelleast squarespanel datar-squared

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$?

Best Answer

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