[R] PLM falling into dummy variable trap -- how to fix?

Andrew Crane-Droesch andrewcd at gmail.com
Sat Feb 22 01:50:48 CET 2014


**Appologies for cross-posting with Stack Overflow**

An example of the problem:

     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.  plm is also convenient for lags.




Thanks,
Andrew



More information about the R-help mailing list