1  Introduction

1.1 Overview

These materials focus on conceptual foundations of generalized linear modeling (GLMs), specifying them, and interpreting the results. Topics include __________.

1.2 Goals

1.3 Prequisites

Readers should be comfortable with multiple linear regression, including building regression models, interpreting regression output, and testing for and interpreting regression coefficients including interactions. The first module can be used to test for preparedness. We recommend UCLA’s Statistical Methods and Data Analytics resources and online seminars for a more in-depth review: https://stats.oarc.ucla.edu/other/mult-pkg/seminars/

In addition, readers should also be comfortable with foundational concepts in statistics like sampling distributions, Null Hypothesis Significance Testing (NHST), and p-values.

1.4 R Packages

These modules will use a variety of R packages which can be installed through the R CRAN network. We encourage readers to become familiar with the syntax of these packages through documentations pages, which we also supply here. We appreciate these packages because they help to visualization and provide clarity to model outputs.

For GLM model fitting, modules will utilize the glm function in the stats base R package, or the glmmTMB package, for fitting GLMs. We refer readers to the glmmTMB package documentation for further information.

1.5 Piping

As of R 4.1.0, a native pipe operator |> has been introduced, and we will use this pipe operator throughout our modules. We appreciate pipes as a way to declutter our code, and we find that they are not that much difficult to follow.

For example, if you wanted to use the sum() function, you would input a vector of numbers into the function as so:

sum(4,5)
[1] 9

Instead, with pipes, you can declare the vector and pipe it (i.e., feed it) to the same function and get the same result:

c(4,5) |> sum() 
[1] 9

This example is kind of contrived, but it is true that pipes allow for passing results/objects to the next function in an elegant way.

1.6 Plot theme

For our visualizations, we have set our plots with a template to show a specific layout for aesthetic purposes. We embedded this template in a variable called mytheme and it is in the code with every plot. The settings of this layout is hidden from view for every module, but we display the custome settings here.

library(tidyverse)
mytheme <- theme_bw(
  base_size = 12
)

1.7 Textbook and Website Resources

We recommend the following textbooks and websites for more in-depth readings of GLMs. We also extend our thanks for these resources as they have helped us create our modules.

  • Faraway, J.J., (2016). Extending the linear model with R: Generalized linear, mixed effects and nonparametric regression models (2nd ed.). CRC Press.

1.8 Materials

All materials are available for download in the appendix. The following are available for download:

  • Data: the data used in each chapter
  • R Script: an R script of the code used in each chapter
  • Worksheet: a worksheet with questions that follows a similar structure to each chapter, but without answers provided

We recommend that people self-studying download the data and R script and following along with the code and output interpretations in each chapter. Instructors can benefit from downloading the data, code, and worksheets for use in a lab portion in their classes.