Solved – wrong reported Total Sum of Squares in time fixed effects with plm (twoways)

plmr

The summary command of a plm regression with the (effect="twoways") argument reports the same coefficients as a plm regression with manual time dummies (and the default effect="individual") but a much lower total sum of squares (and therefore a much lower R2). Why is this the case?

Example:

library(plm)

individual <- c(rep("AT",5),rep("BE",5),rep("DE",5))
time <- c(rep(2006:2010,3))
set.seed(123)
y <- c(rep(rnorm(15, sd=2)))
x <- c(rep(rnorm(15, sd=3)))

Test <- data.frame(individual=individual, time=time, x=x, y=y)
year.f = factor(Test$time)
dummies = model.matrix(~year.f)
Test <- cbind(Test,dummies)
remove(dummies,year.f)

fe_manual <- plm(y~ x+year.f2007+year.f2008+year.f2009+
year.f2010,data=Test,model="within")
summary(fe_manual)

fe_twoways <- plm(y~ x, data=Test,model="within",effect="twoways")
summary(fe_twoways)

The problem doesn't look very bad here (we go from total sum of squares of 38.7 in the manual model to 30.1 in the twoways model), but in my real sample, this problem gets me from an R2 of 42% to one of 3%. The problem gets much bigger with more data.

Any help would be appreciated!

edit: You can see that the twoways model calculates time fixed effects by running:

fixef(fe_twoways)

Strangely, these coefficients are again different from the manual model.

Best Answer

As far as I know, in contrast to the lfe-package, the plm-package does not report $R^2$ and adjusted $R^2$ for the full model, but only for the projected model. This blog-entry should answer your question.

Related Question