Class 6 · Generalized Linear Models

STAT 517: Advanced Statistical Models · Fall 2026

This interactive companion follows the Class 6 notes (Chapter 5). We see why a conditional mean may need a link, identify the three GLM components and basic assumptions, and fit four short examples: Bernoulli, Poisson, Gamma, and Gaussian. We then compare predictions on the link scale and the response scale.

Each WebR code box runs R directly in your browser. Press Run Code, inspect the result, change something, and run it again. Run the cells in order because later cells use objects created earlier.

The page preloads the faraway package for the wafer data and includes data/crabs.txt and data/student_awards.csv, the same public data used in the class code companion.

Setup and data

Keep every plot small, and keep multi-panel plots inside a single cell, because the layout set by par() does not carry over from one cell to the next.

The wafer data contain resistivity measurements from 16 wafers and four experimental factors. Each factor has levels - and +, with - as the reference.

5.1 Why generalize the linear model?

5.2 Basic GLM assumptions

A standard independent-response GLM rests on three basic assumptions:

  • Random component. The chosen family describes the response conditional on the predictors. Its conditional variance is \(p_i(1-p_i)\) for Bernoulli responses and \(\mu_i\) for Poisson responses.
  • Link and systematic component. The conditional mean satisfies \(g(\mu_i)=\eta_i=\beta_0+\sum_j\beta_jx_{ij}\) for the terms included. “Linear predictor” means linear in the coefficients.
  • Conditional independence. Responses from distinct units are independent given the modeled predictors. Repeated measurements on the same person generally require a model that accounts for their dependence.

Normality and constant conditional variance are features of a Gaussian identity-link GLM, not requirements for every GLM. No distributional assumption is imposed on the predictors themselves. Interpretation also depends on data quality and the study design.

5.3 Fitting GLMs in R

These four examples illustrate fitting syntax and coefficient output. We will develop interpretation, inference, and model checks in later chapters. The estimates are rounded to four decimal places, as in the handout.

5.4 Takeaways

  • A GLM combines a conditional response distribution, a linear predictor, and a link function.
  • The link transforms the conditional mean; its inverse returns a mean on the scale of the modeled response.
  • An appropriate conditional family and mean/link relationship, together with conditional independence, are the three basic assumptions.
  • glm() uses the same fitting interface for all four examples.
  • type = "link" returns the fitted linear predictor; type = "response" returns its inverse-link mean.

Next, the Bernoulli GLM with the logit link becomes logistic regression. One predictor comes first, followed by several predictors and conditional interpretation.