|
I was interested in this discussion, and wondered about results from an extreme case -- say just five clusters, with six observations in each. The results of a quick simulation, and the R code for conducting the simulation, are below. The first line includes the means across 1000 simulations (which take just a couple minutes to run), and the second line the standard deviations. The means should all be 1s.
Maybe people will find this useful. The biases don't seem large to me, but there are lots of other issues to take into account. I haven't checked whether the estimated SEs are anti- (or over-)conservative, for instance, though that wouldn't be hard to do.
=================================================================
library(lme4.0)
nsims <- 1000
set.seed(080813)
dgp <- function(N=5,n=6) { within(data.frame(grp = gl(N,n), x1 = rnorm(N*n), x2 = runif(N)[rep(1:N, each=n)]), y <- 1 + x1 + x2 + rnorm(N)[grp] + rnorm(N*n)) } # function to generate the data
c.mer <- function(mod) { c(fixef(mod), c(unlist(lapply(VarCorr(mod), diag)), attr(VarCorr(mod), "sc")^2)) } # function to extract FEs, REs
sim <- function(N, n) { c.mer(lmer(y ~ x1 + x2 + (1 | grp), dgp())) } # function to run a simulation
apply(sapply(1:nsims, sim), 1, function(xx) c(mean(xx),sd(xx))) # run nsims simulations, get means and SDs
[1,] 1.050036 1.0013884 0.9049677 1.0322423 1.0104995
[2,] 1.429368 0.2163859 2.7632334 0.9928147 0.2887274=================================================================
Malcolm Fairbrother
|