I expect to calculate 95% confidence intervals around my tiered model coefficient estimates.
I have no problem for models with one grouping variable, but the bootstrap method that I executed ( http://www.ats.ucla.edu/stat/r/dae/melogit.htm ) essentially broke when I added to an additional grouping variable.
I researched bootMer (the recently implemented part of lme4) with the same result.
Here is an example of a problem:
---------------------------- EDITED enable reproducible example ------------- ----- ----------
Useful comments on this question and the work in this example gave the answer - this is not adding a second grouping variable as such, but a lack of a grouping variable that causes the problem.
Here is a well-developed example for everyone who comes across this.
Here is a simple function to illustrate ...
FUN <- function(fit) {return(fixef(fit))}
Sample data (full)
grouper1 <- as.factor(sample(letters[1:20], 1000, replace = TRUE))
grouper2 <- sample(letters[1:2], 1000, replace = TRUE)
DV<-rnorm(1000)
IV<-rnorm(1000)
example<-data.frame(grouper1, grouper2, DV, IV)
Works well with this data.
one_grouper<-lmer(DV ~ IV + (1 | grouper1), data=example)
> bootMer(one_grouper,FUN, nsim=1)
Call:
bootMer(x = one_grouper, FUN = FUN, nsim = 1)
Bootstrap Statistics :
original bias std. error
t1* 0.005286026 0.041665542 NA
t2* 0.009642498 -0.003707219 NA
>
> two_grouper<-lmer(DV ~ IV + (1 | grouper1) + (1 | grouper2), data=example)
>
> bootMer(one_grouper,FUN, nsim=1)
Call:
bootMer(x = one_grouper, FUN = FUN, nsim = 1)
Bootstrap Statistics :
original bias std. error
t1* 0.005286026 -0.03465914 NA
t2* 0.009642498 -0.01361108 NA
BUT, when we introduce the omission in the grouping variable ...
example$missinggroups <- with(example, ifelse(randommissing=="f", NA,grouper1))
> one_grouper<-lmer(DV ~ IV + (1 | missinggroups ), data=example)
>
> bootMer(one_grouper,FUN, nsim=1)
Call:
bootMer(x = one_grouper, FUN = FUN, nsim = 1)
Bootstrap Statistics :
WARNING: All values of t1* are NA
WARNING: All values of t2* are NA
Warning message:
In bootMer(one_grouper, FUN, nsim = 1) : some bootstrap runs failed (1/1)