Thanks both. That confirms what I suspected but wanted to check.

For effects within groups (if the X variable were at level 1), group mean-centering would work to eliminate the bias, obviating the need for a fixed effects approach with greater variance and thus in many instances higher overall RMSE (see e.g., http://polmeth.wustl.edu/media/Paper/ClarkLinzerREFEMar2012.pdf). But the effects across groups will be biased (and fixed effects can't estimate those).

I'd just never seen this issue addressed in quite these terms in a multilevel/mixed model context.

- Malcolm



On 4 Apr 2012, at 13:08, Andrew Miles wrote:

> I agree that an instrumental variable might be the best bet for an Xj at level 2.  
> 
> If the Xj variable were at level 1, you could probably use a fixed effects approach that removes all between group/individual variance, effectively controlling for group-level characteristics whose effects do not change across level 1 units.  This is usually used with longitudinal data, but certainly could be adapted to other nested data structures as well.  See
> 
> Allison, Paul D. 2009. Fixed Effects Regression Models. Los Angeles, C.A.: Sage.
> 
> 
> Andrew Miles
> 
> 
> On Apr 4, 2012, at 5:17 AM, Markus Jäntti wrote:
> 
>> On 04/03/2012 08:10 PM, Malcolm Fairbrother wrote:
>>> Dear list,
>>> 
>>> Code below simulates a simple two-level dataset, but where a level-2 covariate (Xj) is correlated with the level-2 random effects (Uj). In fitting the model, using the call below, the estimate for the fixed effect of Xj is substantially biased.
>>> 
>>> Is there a way to recover the correct parameter (1)? Presumably it's possible if one knows the variance-covariance matrix "s", but could it be done without that knowledge?
>>> 
>>> Any thoughts (particularly though not only suggested code) would be much appreciated.
>>> 
>> 
>> In an ordinary least-squares setting, this is the school-book example of a violation of the assumption that the error term in the regression is uncorrelated with the covariate.
>> 
>> To estimate the parameters consistently, you would require and instrument, a variable that is correlated with Xj but not Uj. Whether instrumental-variable estimation has been implemented in a multi-level setting I can not say, but it would probably be possible to do this "manually" by estimating an IV-regression with no regard to multi-level, using the residuals from that to estimate the variance components, then use the implied variance structure to transform the original data and re-estimate the IV-regression. This presupposes the existence of an instrument however, which is usually a big problem.
>> 
>> Best
>> Markus
>> 
>>> - Malcolm
>>> 
>>> 
>>> library(lme4); library(multicore); library(mnormt)
>>> N<- 25
>>> T<- 30
>>> s<- matrix(c(2,0.7,0.7,3), ncol=2)
>>> dgp<- function(N, T, s) {
>>> 	dat<- data.frame(group=1:N, rmnorm(n=N, varcov=s))[rep(1:N,each=T),]
>>> 	names(dat)[2:3]<- c("Xj", "Uj")
>>> 	dat$y<- 1 + dat$Xj + dat$Uj + rnorm(nrow(dat))
>>> 	dat
>>> 	}
>>> res1<- do.call("rbind", mclapply(1:100, function(yy) fixef(lmer(y ~ Xj + (1 | group), dgp(N=N, T=T, s=s)))))
>>> colMeans(res1)
>>> 
>>> _______________________________________________
>>> R-sig-mixed-models@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>>> 
>> 
>> 
>> -- 
>> Markus Jantti
>> Professor of Economics
>> Swedish Institute for Social Research
>> Stockholm University
>> 
>> _______________________________________________
>> R-sig-mixed-models@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
> 


	[[alternative HTML version deleted]]


