如何通过重复观察在大数据上拟合分层模型

How to fit hierarchical models on big data with repeated observations

我正在处理在线行为数据,其中每个用户都有多个伯努利试验。我熟悉在 R 中使用 lme4 拟合分层模型,但现在我的数据集有 ~1MM 唯一用户和每个 1-10 个观察值,lme4 模型在我的 运行 上无休止地使用苹果电脑专业版。我以前只为几千名用户安装过这样的模型,运行 时间是可控的。

library(lme4)
glmer(outcome ~ treatment + (1|user_id), family = 'binomial', data = mydata)

我应该如何实际处理将分层模型拟合到如此大的数据集?

有几种方法可以加快 glmer:

  • 尝试在 glmer 调用中设置 nAGQ = 0
  • 尝试在 glmerControl
  • 中指定 "nloptwrap" 作为优化器
  • 尝试在 glmerControl
  • 中指定 calc.derivs = F

More info here

# code example
glmer(
    outcome ~ condition + (1|user_id),
    family = "binomial", 
    data = mydata, 
    nAGQ = 0,
    control = glmerControl(optimizer = "nloptwrap", calc.derivs = FALSE)
)