# Advantage of within transformation over pooled OLS with dummies?

First, apply the within transformation (fixed effects transformation) on a panel data set. Then, apply pooled OLS with dummies for each cross-sectional unit on the same panel data set.

When you compare both regression results you get exactly the same estimates of the coefficients for the exogeneous variables, also the standard errors and the t-values are the same.

Even the unit-specific dummy estimates are equal to the unit-specific unobserved effects you can estimate after applying the within transformation regression. Well, there is one caveat in this respect: You have to add the intercept of the pooled OLS regression to a dummy estimate to get the respective unobserved effects estimate from the within transformation.

The only difference I figured out, is that the within transformation appears to be less efficient in estimating the unit-specific unobserved effects. So, ceteris paribus, the p-values of the unit-specific dummy estimates for the pooled OLS dummy regression are lower than the p-values of the unit-specific unobserved effects from the within transformation (I'm not sure why that happens?).

Hence, performing a pooled OLS regression with unit-specific dummies appears to be supperior to performing a basic within transformation regression. Still, the latter appears to be more often applied. Is there a reason for that? To come back to the title of this post: Is there an advantage of a within transformation over pooled OLS with dummies?

EDIT:
So, as I understood, there appears to be only a computational advantage of the within transformation. Now, the essential question for me is: Why are the p-values of the unit-specific dummy estimates for the pooled OLS dummy regression lower than the p-values of the unit-specific unobserved effects from the within transformation? This really baffles my mind. Because, for small panels (where the computational burden is low), the dummy regression would be advantageous over the within transformation as it yields estimates of the unobserved effects (dummies) with lower p-values?!

EDIT #2: See @ChristophHanck's answer, which solved the mistery of getting different p-values. I incorrectly included an intercept into the pooled OLS dummies regression. After excluding the intercept, the p-values where the same for both models.

• In my understanding, the main (computational) advantage of within is described in my answer to this question: stats.stackexchange.com/questions/201919/… Can you elaborate/illustrate what you mean by less efficiency? If the estimates are always the same, how can one estimator be less efficient than another? – Christoph Hanck Dec 8 '20 at 6:56
• Thank you for your answer @ChristophHanck! So, when having a small panel (low number of cross-sections), there does not appear to be an advantage of the within transformation, as the computational burden is low(?) – Beethoven_90 Dec 8 '20 at 16:33
• @ChristophHanck: well, maybe my terminology was improper in this regard. With less efficient, I meant that the t-values (of the dummies) are much larger and hence the p-values are much smaller when performing the dummies pooled OLS regression in contrast to the p-values of the unobserved effects of the within transformation. I really wonder why that is the case (I hope this is not an erroneous result from the plm package in R). Any idea why that happens? Because, based on this, for small panels (low n), the dummy regression appears to be advantegeous over the within transformation. – Beethoven_90 Dec 8 '20 at 16:34
• Shrinkage of the parameters occurs because the pooled model has more dfs. – user234562 Dec 8 '20 at 18:40
• @user332577 Really? As I understood, for the within transformation, one df is lost for the time-demeaning of every cross-section. For the pooled OLS with dummies, you lose one df for every cross-section dummy. So, if you have 20 cross-sections, you should lose 20 dfs in both cases?? – Beethoven_90 Dec 8 '20 at 19:04

## 1 Answer

As stated in the comments, given that either way of computing the fixed effects leads to numerically the same estimates, there should also be no reason to expect either approach to be more "efficient" (in the statistical sense of an estimator's property), and thus to lead to smaller p-values. This is also not the case, as this illustration demonstrates:

library(plm)

# generate some data
m = 2
n = 20
beta = -2
alpha = rep(runif(n), each=m)
X <- rnorm(m*n)
u <- rnorm(m*n)
y <- alpha + X*beta + u

paneldata <- data.frame(rep(1:n,each=m),rep(1:m,n), y, X) # first two columns are for plm to understand the panel structure
within.reg <- plm(y~X, data = paneldata, model = "within")
FEs <- fixef(within.reg) # retrieve fixed effect estimates
summary(FEs) # report these along with p-values

# dummy approach
dummy.matrix <- matrix(c(rep(1,m), rep(0,n*m)), nrow = n*m, ncol= n) # throws a warning, but indeed intended here as vector is longer than column dimension so that the recycling R then does starts at the right position in each new column
summary(lm(y~dummy.matrix+X-1)) # intercept suppressed to avoid nmulticollinearity, as we have one dummy per unit

# same p-values:
all.equal(summary(FEs)[,4], summary(lm(y~dummy.matrix+X-1))\$coefficients[1:n,4], check.attributes = F) # TRUE


The numerical advantages I mention below only refer to the work the computer has to do - they are irrelevant to the statistical precision of the estimator and hence have no impact on the p-values etc.

One point where our approaches might differ that I could think of is that you talk about an overall intercept that you add in a pooled regression (amounting to summary(lm(y~dummy.matrix+X)) in the code above). Then, the individual-specific intercepts would measure the distance to that overall intercept (omitting one category which serves as the baseline category) and thus also produce different point estimates. Correspondingly, p-values would be for the hypothesis that the intercepts differ significantly from the overall intercept, and not from zero.

Of course, if different hypotheses are tested, there is no longer a reason to expect p-values to agree.

The situation is analogous to the textbook example of avoiding the dummy-variable trap of either specifying an intercept and a, say, dummy for women or no intercept and dummies for both men and women (assuming of course that everybody in the dataset identifies himself/herself as either man or woman).

• Thank you, this answer solve the mystery. You were totally right on the point where our approaches might differ. I did the pooled OLS regression with an intercept. So, assuming a panel with 20 indivduals, I had one intercept which represented the heterogeneity of individual #1 and I had 19 dummies representing the heterogeneity of the rest. Hence, the p-values for the dummies resulted from the hypothesis that the heterogeneity (unobserced effect) of an indivual is not different to individual #1. Which is, as you said, a different hypothesis, resulting in different p-values. – Beethoven_90 Dec 9 '20 at 17:13
• Also, after analysing your illustration code, I realised that you can suppress the intercept in R, by including "-1" into the regression. That was new for me, thanks for that! (btw: there seems to be a small error in this line of your code: dummy.matrix <- matrix(c(rep(1,m), rep(0,n*m)), nrow = n*m, ncol= n). -> number of rows are unequal). – Beethoven_90 Dec 9 '20 at 17:14
• Indeed, I should have (and have now) clarified the -1 in the code. Also, the code for dummy.matrix should have been (and is now) commented better. The line indeed throws a warning, but is nevertheless intended that way as vector is longer than the column dimension so that the recycling R then does starts at the right position in each new column, producing the nonzero entry for each column (unit) m positions further down. That said, there may surely be more elegant ways to code this! – Christoph Hanck Dec 9 '20 at 17:20
• I edited my answer a little to hopefully also clarify this for future readers. – Christoph Hanck Dec 9 '20 at 17:25