# Week 9/10: Generalized Linear Mixed Models (GLMMs)

When the assumption of independence is violated and your Y variable does not fit the assumptions of a Gaussian model, you can apply the same logic we covered in the GLM unit to your data that includes both random and fixed effects. These are called Generalized Linear Mixed Models or GLMMs.

GLMMs are simple in prinicple, but the underlying mathematics are complex. In this lecture we will focus on the basic logic of the models, and I will briefly review some of the packages that can run them.

Our primary activity will be to conduct a deep dive into a novel study, using GLMMs to answer a research question.

### Lecture Topics

- Introduction to GLMMs
- Review: Random vs. fixed effects
- Comparison of packages that run GLMMs in R
- GLMM exercise: Green crab catch rates versus bait type in a field study

### In-class Activities

We will spend much of this week going over a real (as yet unpublished) dataset that is best analyzed in a GLMM framework.

We will use all skills learned so far in this class to conduct the analysis - from setting up the data, to exploring it, to running and interpreting the model output.

### Readings

Please read Ben Bolker’s introduction to GLMMs

### Resources

GLMMs are more complex than what we have covered so far and self-study is recommended.

Some excellent course materials:

Primary literature:

- Harrison, X.A., et al. (Pre-print) A brief introduction to mixed effects modelling and multi-model inference in ecology. PeerJ Pre-prints
- Nakagawa, S., & Schielzeth, H. (2013). A general and simple method for obtaining R2 from generalized linear mixed‐effects models. Methods in Ecology and Evolution, 4(2), 133-142.
- Nakagawa, S., Johnson, P. C., & Schielzeth, H. (2017). The coefficient of determination R2 and intra-class correlation coefficient from generalized linear mixed-effects models revisited and expanded. Journal of the Royal Society Interface, 14(134), 20170213.
- Bolker, B. M., Brooks, M. E., Clark, C. J., Geange, S. W., Poulsen, J. R., Stevens, M. H. H., & White, J. S. S. (2009). Generalized linear mixed models: a practical guide for ecology and evolution. Trends in ecology & evolution, 24(3), 127-135.
- Kain, M. P., Bolker, B. M., & McCoy, M. W. (2015). A practical guide and power analysis for GLMMs: detecting among treatment variation in random effects. PeerJ, 3, e1226.

I cite this book a lot in this class, but where random effects are concerned their reference guide is especially useful:

See also:

In the notes I use ggeffects to plot GLMM output. For more info:

### Files

### Slides

Slides available on Speakerdeck