# Why are individual fixed effects from a "within" and from a dummy variable panel model different?

I am working on a long panel data set with N=34 and T=132. I need to extract fixed effects from plm (within) model and estimation of the same model but including dummies for individuals (N-1) in OLS. However, I do not get the same fixed effects for my individuals from plm (within) and dummy variable model. All the other parameters that I get are exactly the same. Can somebody help me with any possible reasons for this problem please?

Does extracting the fixed effects with the argument type = "dfirst" answer your question? E.g.,

fixef(your_model, type = "dfirst")


To give a precise answer, I'd have to see your code from plm(), but I can still give a general answer that might reveal what is going on. The core of the issue is that there are a variety of ways that fixed effects (as "effects") might be reported. The fixed effects panel model effectively transforms each individual's measurement at a given time point as that time point's deviation from the individual's grand mean over the entire panel.

The individual's "effect" could be reported in several ways. The command plm::fixef() reports $$n$$ values where $$n$$ is the number of individuals. By default, each reported value is the deviation/difference between the individual's panel mean and the grand mean of all observations for $$y$$. However, when you add $$n-1$$ dummy variables, the coefficient for the intercept is the dropped individual's panel mean deviation from the grand mean of $$y$$, and the coefficient for each individual is that individual's deviation from the intercept.

In the output below, individual 1's reported fixed effect value from plm::fixef() is equal to the intercept from the lm() model (0.00472). Then, each individual's coefficient from the lm() output is the deviation from the intercept.

(edit: as noted in the other answer, you can get the equivalent values from the lm() by using plm::fixef(m, type = "dfirst"))

set.seed(99)

df <- data.frame(
individual = rep(1:34,each = 132),
t = rep(1:132, times = 34),
x = rnorm(4488, mean = 1, sd = 1),
y = rnorm(4488, mean = 0, sd = 1))

m <- plm::plm(y ~ x, data = df, model = "within")

# This will give each individual's panel-mean deviation from grand mean
plm::fixef(m)

# This will give individual 1's deviation, then each individual's deviation from that
lm <- lm(y ~ x + factor(individual), data = df)
summary(lm)


         1          2          3          4          5          6          7          8
0.0047219 -0.0284045  0.1517760 -0.1183945 -0.0011442  0.0901698 -0.0378991 -0.0417879
9         10         11         12         13         14         15         16
0.1357880  0.0957661  0.0964060  0.0829114 -0.0592741  0.1212416  0.0773624 -0.1410246
17         18         19         20         21         22         23         24
-0.1183145 -0.0493348  0.0898470 -0.0987910  0.0923552  0.0893971  0.0957151  0.1770503
25         26         27         28         29         30         31         32
-0.0546760  0.0122853 -0.1961002  0.1827902  0.0181183  0.1620981 -0.0165759 -0.0407706
33         34
-0.0263147  0.1020226

Call:
lm(formula = y ~ x + factor(individual), data = df)

Residuals:
Min      1Q  Median      3Q     Max
-3.5630 -0.6518  0.0041  0.6575  3.1722

Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept)           0.004722   0.086760   0.054   0.9566
x                    -0.018293   0.014713  -1.243   0.2138
factor(individual)2  -0.033126   0.121418  -0.273   0.7850
factor(individual)3   0.147054   0.121418   1.211   0.2259
factor(individual)4  -0.123116   0.121418  -1.014   0.3106
factor(individual)5  -0.005866   0.121447  -0.048   0.9615
factor(individual)6   0.085448   0.121418   0.704   0.4816
factor(individual)7  -0.042621   0.121434  -0.351   0.7256
factor(individual)8  -0.046510   0.121421  -0.383   0.7017
factor(individual)9   0.131066   0.121459   1.079   0.2806
factor(individual)10  0.091044   0.121417   0.750   0.4534
factor(individual)11  0.091684   0.121422   0.755   0.4502
factor(individual)12  0.078189   0.121464   0.644   0.5198
factor(individual)13 -0.063996   0.121419  -0.527   0.5982
factor(individual)14  0.116520   0.121440   0.959   0.3374
factor(individual)15  0.072641   0.121442   0.598   0.5498
factor(individual)16 -0.145746   0.121429  -1.200   0.2301
factor(individual)17 -0.123036   0.121503  -1.013   0.3113
factor(individual)18 -0.054057   0.121408  -0.445   0.6562
factor(individual)19  0.085125   0.121426   0.701   0.4833
factor(individual)20 -0.103513   0.121410  -0.853   0.3939
factor(individual)21  0.087633   0.121407   0.722   0.4704
factor(individual)22  0.084675   0.121432   0.697   0.4856
factor(individual)23  0.090993   0.121473   0.749   0.4538
factor(individual)24  0.172328   0.121487   1.418   0.1561
factor(individual)25 -0.059398   0.121486  -0.489   0.6249
factor(individual)26  0.007563   0.121415   0.062   0.9503
factor(individual)27 -0.200822   0.121442  -1.654   0.0983 .
factor(individual)28  0.178068   0.121429   1.466   0.1426
factor(individual)29  0.013396   0.121407   0.110   0.9121
factor(individual)30  0.157376   0.121449   1.296   0.1951
factor(individual)31 -0.021298   0.121409  -0.175   0.8608
factor(individual)32 -0.045492   0.121483  -0.374   0.7081
factor(individual)33 -0.031037   0.121407  -0.256   0.7982
factor(individual)34  0.097301   0.121451   0.801   0.4231
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Residual standard error: 0.9863 on 4453 degrees of freedom
Multiple R-squared:  0.01001,   Adjusted R-squared:  0.002455
F-statistic: 1.325 on 34 and 4453 DF,  p-value: 0.09874