简体   繁体   中英

How to bootstrap Mixed-Effects Model in R

I have a data set (df) in this format

index <- runif(n = 100,min = 0, max = 1)
type1 <- rep("low", 50)
type2 <- rep("high", 50)
type <- c(type1,type2)

level1 <- rep("single", 25)
level2 <- rep("multiple", 25)
level3 <- rep("single", 25)
level4 <- rep("multiple", 25)
level <- c(level1,level2,level3,level4)

block <- rep(1:5, 10)
set <- rep(1:5, 10)

df <- data.frame("index" = index,"type" = type, "level" = level, "block" = block, "set" = set)
df$block <- as.factor(df$block)
df$set <- as.factor(df$set)

I want to create a model that looks like like this

model <- lmer(index ~ type * level + (1|block) + (1|set), data = df)

However, in my original data the fit is bad because the data is bound between 0 and 1. I want to bootstrap this mixed effects model. Any idea on how to achieve boot-strapping for such a model? I want to compare this this full model with sub-models eg. without interaction, or with level or type alone. I also want with confidence intervals for the final model

The confint() function has a method for merMod objects. The following should work:

confint(model, method = "boot", nsim = 1000)

And with multiple CPUs:

confint(model, method = "boot", nsim = 1000,
        parallel = "multicore", ncpus = 8)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM