Small bugs in my simulated data (corrected code below). However, that does not affect my question:
id<-rep(c(1:100),each=2) obs<-rep(c(0:1),100) d<-rep(sample(c(-1,1),100,replace=T),each=2) base.happy<-rep(rnorm(100),each=2) happy<-base.happy+1.5*d*obs+rnorm(200) data<-data.frame(id,obs,d,happy) Daniel Malter wrote: > > Hi all, > > I am statistically confused tonight. When the assumptions to a random > effects estimator are warranted, random effects should be the more > efficient estimator than the fixed effects estimator because it uses fewer > degrees of freedom (estimating just the variance parameter of the normal > rather than using one df for each included fixed effect, I thought). > However, I don't find this to be the case in this simulated example. > > For the sake of the example, assume you measure subjects' happiness before > exposing them to a happy or sad movie, and then you measure their > happiness again after watching the movie. Here, "id" marks the subject, > "obs" marks the pre- and post-treatment observations, "d" is the treatment > indicator (whether the subject watched the happy or sad movie), > "base.happy" is the ~N(0,1)-distributed individual effect a(i), happy is > the measured happiness for each subject pre- and post-treatment, > respectively, and the error term u(i,t) is also distributed ~N(0,1). > > id<-rep(c(1:100),each=2) > obs<-rep(c(0:1),100) > d<-rep(sample(c(-1,1),100,replace=T),each=2) > base.happy<-rep(rnorm(50),each=2) > happy<-base.happy+1.5*d*obs+rnorm(100) > > data<-data.frame(id,obs,d,happy) > > # Now run the random and fixed effects models > > library(lme4) > reg.re<-lmer(happy~factor(obs)*factor(d)+(1|id)) > > reg.fe1<-lm(happy~factor(id)+factor(obs)*factor(d)) > summary(reg.fe1) > > library(plm) > reg.fe2<-plm(happy~factor(obs)*factor(d),index=c('id','obs'),model="within",data=data) > summary(reg.fe2) > > > > I am confused why FE and RE models are virtually equally efficient in this > case. Can somebody lift my confusion? > > Thanks much, > Daniel > -- View this message in context: http://r.789695.n4.nabble.com/Efficiency-of-random-and-fixed-effects-estimator-tp3761611p3761617.html Sent from the R help mailing list archive at Nabble.com. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.