[R-sig-ME] interpretation of random effects variance from glmer() with the Gamma family

Zach Simpson zp@|mp@o @end|ng |rom gm@||@com
Wed Dec 28 23:51:43 CET 2022


Hi Jun,

In the summary of an lme4::merMod object, the standard deviation given
for the 'Residual' is the same as lme4::sigma(), which for
non-Gaussian models is "the square root of the residual deviance per
degree of freedom". 'Variance' is the square of that value.

In this R-sig-ME thread you shared with me, Ben Bolker points out how
things relate for the Gamma family:
https://stat.ethz.ch/pipermail/r-sig-mixed-models/2017q4/026168.html

"In the classic GLM sense `phi=sigma^2=1/shape` is the dispersion
parameter, because we define `variance= V(mu) * phi`,  `V=mu^2`
(`(shape*scale)^2/shape = shape*scale^2 - variance`)."

where shape and scale are the parameters for the Gamma distribution
(in shape-scale form).
(I believe there was a tiny typo there, Ben originally had `variance =
V(mu) / phi` )

Example:

## sim data for mixed-effects case
set.seed(321)
fake_data_mix <- tibble(
  rand_int = rnorm(50, 0, sd = 1)
) %>%
  mutate(
    clust_id = row_number(),
    log_mu = map(rand_int, ~rnorm(n = 30, mean = 5 + .x, sd = 0.2))
  ) %>%
  unnest(cols = log_mu) %>%
  mutate(y = rgamma(n = n(), shape = exp(log_mu), scale = 1))

fit_2_glmer <- glmer(y ~ (1|clust_id), family = Gamma(link = 'log'),
                     data = fake_data_mix)
summary(fit_2_glmer)
# Residual variance: 0.06871; std dev: 0.2621
sigma(fit_2_glmer) ^ 2 # 0.06871
sigma(fit_2_glmer) # 0.2621

Unlike for glm, the dispersion parameter (phi) isn't reported anywhere
by glmer from what I can see...
For the mixed model context, Simon Wood in his 2017 GAM book (Ch. 3;
p. 150 in the 2nd Ed.) gives an REML estimate of phi for GLMMs that
involves the effective degrees of freedom (alas this is a bit over my
head).

Cheers,
Zach Simpson

On 12/5/22 10:50, Jun Yan wrote:
>
> Hi All,
>
> The summary of an lme4::glmer() fit with the Gamma family has a section on random effects. For example:
>
> Random effects:
>  Groups   Name        Variance Std.Dev.
>  Year     (Intercept) 0.002536 0.05036
>  Residual             0.011198 0.10582
> Number of obs: 91, groups:  Year, 12
>
> The function call that I used was
>
> fit2 <- glmer(y ~ (1 | Year), data = finals, family = Gamma(link = "log"))
>
> I understand that the normal random effect of "Year" has variance 0.00256. My question is, doe the variance for the "Residual", 0.011198, mean the variance of the Gamma family or the dispersion parameter (which is the reciprocal of the shape of the Gamma distribution, the same as what is reported from a glm fit)?
>
> Any tips are appreciated.



More information about the R-sig-mixed-models mailing list