Generalized Linear Mixed Models

library(glmm)
data(salamander)
attach(salamander)

The salamander data set is a perfect example of when to use a generalized linear mixed model.

We have non-normal response type because we are looking at whether or not the salamanders mate (binary variable).

We also have correlated data because the salamanders are used in multiple trials.

The glmm package uses a Monte Carlo likelihood approximation technique that is somewhat unique compared to other packages.

The reason this approximation technique is needed is because modern computers cannot handle high dimension integrals. In this particular dataset, we would need to compute an 120-dimensioned integral… simply not a possible feat with today’s technology.

Below is the glmm syntax:

First, we need to set the seed to make results reproducable and also set some reasonable values for m

set.seed(1234)

m<-10^4
fullmod <- glmm(Mate ~ 0 + Cross,
          random = list(~0+Female,~0+Male),
          varcomps.names = c("F","M"), data=salamander,
          family.glmm = bernoulli.glmm, m=m)

The summary of fullmod provides a decent amount of useful information.

summary(fullmod)
## 
## Call:
## glmm(fixed = Mate ~ 0 + Cross, random = list(~0 + Female, ~0 + 
##     Male), varcomps.names = c("F", "M"), data = salamander, family.glmm = bernoulli.glmm, 
##     m = m)
## 
## 
## Link is: "logit (log odds)"
## 
## Fixed Effects:
##          Estimate Std. Error z value Pr(>|z|)    
## CrossR/R    1.197      0.268   4.467 7.92e-06 ***
## CrossR/W    0.657      0.261   2.516   0.0119 *  
## CrossW/R   -2.304      0.326  -7.059 1.67e-12 ***
## CrossW/W    1.176      0.272   4.317 1.58e-05 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## 
## Variance Components for Random Effects (P-values are one-tailed):
##   Estimate Std. Error z value Pr(>|z|)/2    
## F    1.785      0.329   5.422   2.95e-08 ***
## M    1.323      0.243   5.446   2.57e-08 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

3 of the crosses of salamanders appear (R/R, R/W, & W/W) to be significant to the log odd of mating and both variances are also significant.

This is definitely a package I want to keep in mind moving forward. There are so many scenarios where there are non-normal response types and correlated data that can be modeled in this fashion.