# Within model with plm package

I have a question about plm package.

My code is:

fixedmodel <- plm(formula=Inv_ret~Firm.size+leverage+Risk+Liquidity+Equity,
data=datanewp, model="within")


In the plm vignette the authors write:

This is called the fixed effects (a.k.a. within or least squares dummy variables) model, usually estimated by ols on transformed data, and gives consistent estimates for beta.

I wonder then if plm package assumes that least squares dummy variable model is estimated with model="within in the plm package? In other words, if wihin is actually least squares dummy variable model in plm?

On the other hand, if I refer to some other site they write:

There are several strategies for estimating a fixed effect model. The least squares dummy variable model (LSDV) uses dummy variables, whereas the “within” estimation does not. These strategies, of course, produce the identical parameter estimates of regressors (nondummy independent variables).

So I guess the authors of plm package mean that they actually use within model but compute the unique group specific intercepts from within transformation later. Am I correct?

The two estimators are computed differently, but are numerically identical, so essentially it doesn't matter. The within estimator is computationally easier since it keeps the size of the design matrix in check, and I would think that is how the within estimator is implemented. Here is some R code to demonstrate this

library(plm)
data("Produc", package = "plm")
plmResults <- plm(log(gsp) ~ log(pcap) + log(pc) + log(emp) + unemp, data = Produc,
index = c("state","year"))
summary(plmResults)

regResults <- lm(log(gsp) ~ as.factor(state) + log(pcap) + log(pc) + log(emp) + unemp,
data = Produc)
summary(regResults)


Or, if you prefer, some Stata code,

webuse nlswork
xtset idcode

xtreg ln_w grade c.age##c.age c.ttl_exp##c.ttl_exp c.tenure##c.tenure ///
2.race not_smsa south, fe

areg ln_w grade c.age##c.age c.ttl_exp##c.ttl_exp c.tenure##c.tenure ///
2.race not_smsa south, absorb(idcode)


A proof using the Frisch-Waugh-Lovell theorem can easily be given. Note one crucial point that for a large number of groups, that is, $n\to \infty$, the estimates of the coefficients on the group dummies are not consistent.