使用R中的lme4包计算GLMM Gamma Regression的置信区间时使用哪种方法

机器算法验证 r lme4-nlme 咕噜咕噜 伽马分布
2022-04-02 10:28:55

我正在使用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

相反,我们可以将方法设置为Waldboot计算置信区间。

# 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该方法只能计算固定效应参数的置信区间。任何见解或建议将不胜感激。

1个回答

我发现这个博客有助于 RE 找到用于估计 GLM(M) 的 CI:

https://fromthebottomoftheheap.net/2018/12/10/confidence-intervals-for-glms/