[R] PLM falling into the dummy variable trap -- how to fix?
Andrew Crane-Droesch
andrewcd at gmail.com
Tue Mar 11 07:07:37 CET 2014
Dear list, CC Dr Croissant,
I'm tryng to use plm with timeXgroup effects (in addition to the twoway
effects), and running into problems with dummy variables. Eventually I
want to take advantage of pgmm as well, but first I'd like to solve the
problem with the non-dynamic version.
An example:
load(url('http://andrewcd.berkeley.edu/sdat'))
head(sdat)
library(plm)
fem =
plm(y~T+G:t,data=sdat,effect="twoways",model="within",index=c("ID","t"))
summary(fem)
lsdvm = lm(y~ID+T+G:t,data=sdat)
summary(lsdvm)
fem$coef
`fem` is the fixed-effects model (fit with plm), and `lsdv` is the
equivalent least-squares dummy variable model (fit with lm)
It is clear that plm is estimating the coefficients, and indeed that the
coefficients are identical in the two models, as they should be. But
when I go to summarize the results, plm is having a hard time, and I'm
pretty sure that the reason is the timeXgroup fixed effects, some of
which need to be auto-omitted because of the dummy variable trap. (lm,
for example, seems to know how to automatically remove variables that
are exact linear combinations of each other).
How do I get around this? I'd prefer to stay with plm, as it gives much
more parsimonious output than lm with dummy variables for each
cross-sectional unit.
Thanks in advance for any help!
Best,
Andrew
More information about the R-help
mailing list