我正在使用lme4R 中的包来拟合带有家庭 gamma 的 GLMM。下面是模拟 gamma GLMM 拟合的代码示例。
# Load packages
library(tidyverse)
library(lme4)
library(lmerTest)
# Set seed
set.seed(200)
# Create an example data frame
dat <- data_frame(X = rgamma(500, shape = 2),
Group = rep(c("A", "B", "C", "D", "E"), each = 100)) %>%
mutate(R = unlist(map(1:5, ~rnorm(100, .x)))) %>%
mutate(Y = exp(X + R))
# Fit a GLMM with Gamma and log link
fit <- glmer(Y ~ X + (1 | Group), data = dat, family = Gamma(link = "log"))
对于泊松或二项式 GLMM,我们可以使用该confint函数来计算置信区间。但默认设置 ( method = "profile) 不适用于 gamma GLMM。
confint(fit)
Computing profile confidence intervals ...
Error in profile.merMod(object, which = parm, signames = oldNames, ...) :
can't (yet) profile GLMMs with non-fixed scale parameters
相反,我们可以将方法设置为Wald或boot计算置信区间。
# Calculate the confidence interval using the Wald method
confint(fit, method = "Wald")
# 2.5 % 97.5 %
# .sig01 NA NA
# .sigma NA NA
# (Intercept) 2.199512 4.548215
# X 1.018495 1.131192
# Calculate the confidence interval using the boot method
confint(fit, method = "boot")
# 2.5 % 97.5 %
# .sig01 0.4264700 1.9473079
# .sigma 0.8331289 0.9826871
# (Intercept) 2.1469817 4.5461055
# X 1.0202349 1.1340656
# Warning message:
# In bootMer(object, FUN = FUN, nsim = nsim, ...) :
# some bootstrap runs failed (5/500)
我很好奇使用哪种方法以及利弊。据我所知,该Wald方法计算速度很快,而自举方法需要很长时间才能运行。但Wald该方法只能计算固定效应参数的置信区间。任何见解或建议将不胜感激。