简体   繁体   English

如何在R中引导混合效果模型

[英]How to bootstrap Mixed-Effects Model in R

I have a data set (df) in this format 我有这种格式的数据集(df)

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. 但是,在我的原始数据中,拟合是不好的,因为数据绑定在0和1之间。我想引导这个混合效果模型。 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. 没有互动,或单独使用leveltype I also want with confidence intervals for the final model 我还希望最终模型的置信区间

The confint() function has a method for merMod objects. confint()函数有一个merMod对象的方法。 The following should work: 以下应该有效:

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

And with multiple CPUs: 并且有多个CPU:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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