I am using the plm()
function in R with a fixed effects model:
fixed <- plm(Y ~ X, data = pdata, index = c("sireID", "cropNum"), model = "within")
The output is then:
> summary(fixed)
Oneway (individual) effect Within Model
Call:
plm(formula = Y ~ X, data = pdata, model = "within")
Unbalanced Panel: n = 256, T = 1-16, N = 1039
Residuals:
Min. 1st Qu. Median 3rd Qu. Max.
-12.2822 -2.1441 0.0000 1.8906 32.6836
Coefficients:
Estimate Std. Error t-value Pr(>|t|)
X1 0.643017 0.042771 15.0340 <2e-16 ***
X2 1.945723 1.745879 1.1145 0.2654
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Total Sum of Squares: 17203
Residual Sum of Squares: 13330
R-Squared: 0.2251
Adj. R-Squared: -0.029887
F-statistic: 113.439 on 2 and 781 DF, p-value: < 2.22e-16
I want to obtain the intercept for this fixed effects model. Is this possible to do using plm
in R? I tried using the solution given here by adding effect = "twoways"
to the plm()
function but this didn't produce an intercept term.
Best Answer
The fixed effects model your estimating is akin to estimating a separate intercept for each
sireID
. The unit-specific intercepts don't appear in your summary output, but you can ask for them with the following function:fixef(fixed)
.Estimating fixed effects along the other dimension (e.g.,
effect = "twoways
) isn't going to return a global intercept. The main takeaway from the post you referenced is that the overall intercept $\alpha$ is perfectly collinear with $\alpha_i$, as the sum of all the unit-specific effects (i.e., $\alpha_i$'s) is one.Estimating your equation using
lm()
and including dummies for all units will return an intercept, but the intercept is simply the effect for the omitted dummy. To see this in practice, I will use theProduc
dataset (U.S. state production from 1970 to 1986) from theplm
package.The
fixef()
function extracts the fixed effects from aplm
object. The output below reports the unique state-specific intercepts. Remember the effect for Alabama in the first row.Estimating dummies for each state using
lm()
results in equivalent estimates. However, we must drop a state since all the state dummies sum to one. Thestate
variable in theProduc
dataset is a factor variable; it's ordered alphabetically. R drops the first factor by default, which is Alabama.Note how the indicator for Alabama doesn't necessarily get dropped; it actually gets absorbed into the intercept. The omitted state effect could be any state in the panel.
In short, the intercepts usually aren't the focus in a fixed effects analysis; they're nuisance. In your case, the principal focus should be on
X1
andX2
.In accordance with the suggestion provided by @Helix123, I wanted to note that there is, in fact, a
within_intercept()
function in theplm
package. I always found it a bit artificial but it does return an "overall intercept" for within models and its accompanying standard error.Under the hood, it's actually a weighted mean of the fixed effects. You could calculate this fairly easily in the one-way case using the following code:
Simply feed the
weighted.mean()
function the individual state effects, followed by a numeric vector of the weights, and you got your overall intercept.