3
$\begingroup$

Motivating Question

I was fitting some models in R and recalled that significance terms are shown for random effects in the mgcv package for Generalized Additive Mixed Models (GAMMs), but this is not provided in the summary fit for Generalized Linear Mixed Models (GLMMs) in the lmerTest package, despite having significance tests for fixed effects terms. My assumption is purely that because the gam function already comes pre-loaded with Wald tests for spline curves, this essentially does the significance testing by default, but such an operation isn't included in GLMM summaries for some reason.

I assume then that there is some theoretical or practical reason for why this isn't done in GLMMs. My first guess is that because random effects are considered "noise" variables in linear models, we wouldn't really want to test for their effects. But my secondary thought is whether or not these random effects are even that useful. We can check this heuristically with ICC calculations of clustering and perhaps ANOVA comparison of the models in R to see if different fits or REs constitute meaningful differences in model results, but this still seems fairly indirect compared to the GAMM fits.

As an example, I have fit a GLMM and GAMM to the same data with their consequent summaries below using the carrots data in lmerTest.

#### Libraries ####
library(mgcv)
library(lmerTest)

#### Gaussian Linear Mixed Model ####
lmer.fit <- lmer(Preference
           ~ sens2
           + Homesize
           + (1 | Consumer),
           data=carrots)
summary(lmer.fit)

#### Gaussian Additive Mixed Model ####
gam.fit <- gam(Preference
                 ~ s(sens2)
                 + Homesize
                 + s(Consumer, bs = "re"),
                 data=carrots,
                 method = "REML")
summary(gam.fit)

GLMM Summary

Linear mixed model fit by REML. t-tests use Satterthwaite's method [
lmerModLmerTest]
Formula: Preference ~ sens2 + Homesize + (1 | Consumer)
   Data: carrots

REML criterion at convergence: 3755.9

Scaled residuals: 
    Min      1Q  Median      3Q     Max 
-3.4353 -0.5494  0.0259  0.6311  2.8154 

Random effects:
 Groups   Name        Variance Std.Dev.
 Consumer (Intercept) 0.1918   0.4379  
 Residual             1.1111   1.0541  
Number of obs: 1233, groups:  Consumer, 103

Fixed effects:
              Estimate Std. Error         df t value Pr(>|t|)    
(Intercept)  4.906e+00  7.067e-02  1.010e+02  69.421   <2e-16 ***
sens2        7.067e-02  8.159e-03  1.129e+03   8.662   <2e-16 ***
Homesize3   -2.401e-01  1.057e-01  1.010e+02  -2.271   0.0253 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Correlation of Fixed Effects:
          (Intr) sens2 
sens2      0.000       
Homesize3 -0.668  0.000

GAMM Summary

Family: gaussian 
Link function: identity 

Formula:
Preference ~ s(sens2) + Homesize + s(Consumer, bs = "re")

Parametric coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  4.90628    0.07066  69.434   <2e-16 ***
Homesize3   -0.24013    0.10572  -2.271   0.0233 *  
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

Approximate significance of smooth terms:
               edf  Ref.df      F p-value    
s(sens2)     3.648   4.379 19.544  <2e-16 ***
s(Consumer) 68.331 101.000  2.091  <2e-16 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

R-sq.(adj) =  0.201   Deviance explained = 24.9%
-REML =   1875  Scale est. = 1.1016    n = 1233

Summary

So what gives? Is there a good reason for this difference or is it just an accident of programming history that has resulted in this discrepancy? This is really the only resource I've found so far on why this isn't done in GLMM, but its fairly brief.

$\endgroup$

1 Answer 1

3
$\begingroup$

(Some thoughts) I suspect it has something to do with...

Random effects as splines is somewhat taking the concept of random effect to it's philosophical and practical limit, something Hodges calls new-style random effects.

In the GLMM, one is literally estimating one or more variance terms, and the estimates of the random effects come as the posterior modes of some distribution. Formal analysis has been performed using generalized likelihood ratio tests (via anova()), but also noting that this test is conservative as the null hypothesis (setting a variance term to 0) is on the boundary of the parameter-space.

In the GAMM, we're just fitting another spline. That that spline happens to walk and quack like a random effect is just convenient for the purposes of estimating the things we want to estimate.

Simon Wood has been working on improving the p-values in these tests; the method he proposed for normal smooth terms doesn't work very well for smooth terms that are fully penalised (which includes ranef smooths). So he also did some work on tests for fully penalized terms too. Two papers were published by Simon in 2013:

  • Wood, S.N. (2013a) A simple test for random effects in regression models. Biometrika 100:1005-1010

  • Wood, S.N. (2013b) On p-values for smooth components of an extended generalized additive model. Biometrika 100:221-228

which describe the difference approaches.

It seems natural for Simon to implement the method he proposed into the software he wrote. And as Simon notes in the opening to Wood (2013a), the options available for testing random effects in GLMMs are "quite crude approximations that often lack power".

And I really think it is this latter point that is pertinent; a GLRT anova() already provides one test of a random effect, and absent any improvements to the theory etc, it doesn't seem worth the effort to change the summary output. As Simon already had infrastructure for reporting the significance of smooths in summary.gam() and the ranef smooth is just a smooth, it did however make sense to report these test results there. They are also very computationally demanding (hence the option to turn them off in summary.gam()).

$\endgroup$
1
  • $\begingroup$ Thank you Gavin. Another great answer. $\endgroup$ Nov 28, 2022 at 9:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.