# Solved – Which method to use when calculating the confidence interval of GLMM Gamma Regression with the lme4 package in R

I am fitting a GLMM with family gamma using the `lme4` package in R. Below is a code example to simulate the gamma GLMM fitting.

``# 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")) ``

For poisson or binomial GLMM, we can use the `confint` function to calculate the confidence interval. But the default setting (`method = "profile`) is not working for 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 ``

Instead, we can set the method to be `Wald` or `boot` to calculate the confidence interval.

``# 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) ``

I am curious about which method to use and what would be the pros and cons. As far as I can tell, the `Wald` method is fast to compute, while the bootstrapping method takes a long time to run. But `Wald` method can only compute the confidence interval of the fixed-effect parameters. Any insights or suggestion would be appreciated.

Contents