Chapter 19 of 22 Statistics guide · Part 5: Beyond the basics

Generalized Linear Models: Logistic, Poisson and Negative Binomial Regression, and GLMMs

Yes/no outcomes, proportions and counts break the assumptions of ANOVA: their variance depends on the mean and they cannot go below zero. Generalized linear models (GLMs) handle them on their own terms. This chapter covers link functions, logistic regression for scours and seedling emergence, Poisson and negative binomial models for counts, overdispersion, and generalized linear mixed models (GLMMs, PROC GLIMMIX) for designed experiments.

  • Plant and animal examples
  • Worked by hand and in R
  • Sources cited
  • Free tools to try it

Quick answers

What is a generalized linear model?
An extension of linear models to responses that are not normal. It has three parts: a distribution (binomial, Poisson…), a link function (logit, log…), and a linear predictor of treatments and covariates.
When should I use logistic regression?
When the response is yes/no (sick or healthy, pregnant or not) or a count out of a known total (seeds emerged out of 100). It models the probability through the logit link.
What is Poisson regression?
A GLM for counts (weeds, insects, days sick) using the log link. Treatment effects come out as rate ratios: 0.44 means 56% fewer events.
What is overdispersion?
More variation than the binomial or Poisson distribution allows. It makes p values too small. Check the ratio of Pearson chi-square to its degrees of freedom; values well above 1 signal it.
What is the difference between a GLM and a GLMM?
A GLMM adds random effects, such as blocks, pens or animals, to a GLM. It is the right tool for counts and proportions from blocked, split-plot or repeated-measures experiments.
Should I transform percentages and counts instead?
Transformations were the old fix. GLMs and GLMMs usually give more accurate tests and estimates on the original scale, especially with small counts or extreme proportions.
On this page
  1. Quick answers
  2. Why counts and proportions need a different model
  3. Logistic regression
  4. Poisson and negative binomial regression for counts
  5. GLMMs: GLMs with random effects (PROC GLIMMIX, glmer)
  6. Where the chi-square test fits
  7. GLMs and GLMMs in R and SAS
  8. Key takeaways
  9. Questions people ask
  10. Sources

Why counts and proportions need a different model

  • A proportion is bounded by 0 and 1, and its variance p(1 − p)/n is largest near 50% and shrinks toward 0% and 100%.
  • A count cannot be negative, is skewed when small, and its variance grows with its mean.
  • An ANOVA on raw values can predict impossible values (−0.2 weeds, 107% emergence) and gives wrong standard errors.

A GLM keeps the data on their scale and links the mean to the treatments through a function that respects the bounds. Kaps and Lamberson's final chapter covers these "discrete, categorical and other non-normal dependent variables".

ResponseDistributionLinkEffects reported as
Continuous, normalNormalIdentityDifferences in means
Yes/no, x out of nBinomialLogit (or probit)Odds ratios; back-transformed probabilities
CountsPoissonLogRate ratios
Overdispersed countsNegative binomialLogRate ratios
Ordered scoresMultinomialCumulative logitOdds ratios
Positive, right-skewedGamma or lognormalLogRatios

Logistic regression

log[p / (1 − p)] = β₀ + β₁x … where p / (1 − p) is the odds

The logit link maps a probability between 0 and 1 onto the whole number line. Coefficients are log odds ratios; exponentiated, they are odds ratios.

Probit regression uses the normal distribution's quantiles instead of the logit; results are nearly identical in shape and it is traditional for dose-mortality (LD50) work and threshold traits in animal breeding.

Poisson and negative binomial regression for counts

log(mean count) = β₀ + β₁x …, effects reported as rate ratios = e^β

  • Always check overdispersion for counts: Pearson χ² ÷ residual df well above 1 (say, above 1.5 to 2) is a warning.
  • Fixes: negative binomial, quasi-Poisson, or an observation-level random effect in a GLMM.
  • Many zeros beyond what the model expects may need a zero-inflated or hurdle model.
  • For counts per unit of effort (weeds per m² from quadrats of different sizes), include log(area) as an offset.

GLMMs: GLMs with random effects (PROC GLIMMIX, glmer)

Designed experiments add blocks, pens, main plots and repeated measures. A generalized linear mixed model combines a GLM's distribution and link with a mixed model's random effects, so a split-plot of germination percentages or a blocked trial of weed counts is analyzed as designed.

  • Conditional vs marginal means: GLMM estimates are on the link scale; back-transform the least squares means (ilink in GLIMMIX, type = "response" in emmeans) for probabilities or counts.
  • Estimation: Laplace or adaptive quadrature are preferred over pseudo-likelihood when comparing models and for small counts.
  • Variance components near zero are common (the block variance for emergence was estimated at 0); keep the term to reflect the design.

Stroup (2015) showed that GLMMs give more accurate tests than transformation-based ANOVA for the proportion and count data typical of plant and soil science; the same holds in animal science for reproduction and health outcomes.

Where the chi-square test fits

A chi-square test of independence compares proportions in a contingency table, such as scours (yes/no) by diet: χ² = 6.0, df = 3, p = 0.11. It cannot handle blocks or covariates, and with expected counts below 5 (as here) its p value is unreliable; use Fisher's exact test or logistic regression. Think of it as the simplest GLM.

GLMs and GLMMs in R and SAS

In R

dat$supp <- ifelse(dat$diet == "Control", "Control", "Supplemented")
lg <- glm(scours == "yes" ~ supp, family = binomial, data = dat)
exp(coef(lg)); drop1(lg, test = "Chisq")                   # odds ratio, LR test
ps <- glm(scour_days ~ supp, family = poisson, data = dat)
sum(residuals(ps, "pearson")^2) / ps$df.residual          # dispersion ratio
nb <- MASS::glm.nb(scour_days ~ supp, data = dat)          # negative binomial
library(lme4)
glmer(cbind(emerged, seeds_sown - emerged) ~ variety + (1 | block),
      family = binomial, data = wheat)                     # binomial GLMM

In SAS

proc glimmix data=wheat method=laplace;
  class block variety;
  model emerged/seeds_sown = variety / dist=binomial link=logit oddsratio;
  random intercept / subject=block;
  lsmeans variety / ilink;          /* back to probabilities */
run;

proc glimmix data=pigs;
  class supp;
  model scour_days = supp / dist=negbin link=log;
  lsmeans supp / ilink;
run;

Key takeaways

  • Use GLMs for yes/no, proportions and counts: a distribution, a link function and a linear predictor.
  • Logistic regression gives odds ratios; Poisson and negative binomial give rate ratios.
  • Check counts for overdispersion; ignoring it makes p values far too small.
  • Binary outcomes carry little information per animal; plan larger trials or count-out-of-n measurements.
  • GLMMs (glmer, PROC GLIMMIX) bring blocks, plots and repeated measures into GLMs: analyze as designed.

Questions people ask

What is an odds ratio?

The odds of the event in one group divided by the odds in another. 1 means no difference; 0.5 means half the odds. For rare events it approximates the ratio of probabilities.

Can I analyze percentages with ANOVA?

If they are averages over many units and lie mostly between 20% and 80%, ANOVA is often adequate. For counts out of a known number, extreme percentages or small numbers, use a binomial GLM or GLMM.

What is the deviance?

A measure of lack of fit in GLMs, used like the residual sum of squares. Differences in deviance between nested models give likelihood ratio (chi-square) tests.

What is the difference between PROC GENMOD and PROC GLIMMIX?

GENMOD fits GLMs and GEEs (marginal models for correlated data). GLIMMIX fits GLMs and GLMMs with random effects, and is the usual choice for designed experiments.

What is complete separation?

When a predictor perfectly separates outcomes, for example no animals with the event in one group. Logistic estimates then diverge; use exact methods, Firth's penalized likelihood or pooling.

Sources

  • Stroup, W. W. (2015). Rethinking the analysis of non-normal data in plant and soil science. Agronomy Journal, 107(2), 811–827.
  • Kiernan, K. (2018). Insights into using the GLIMMIX procedure to model categorical outcomes with random effects. SAS Global Forum, paper SAS2179.
  • Kaps, M., and Lamberson, W. R. (2017). Biostatistics for Animal Science (3rd ed.), chapter on discrete, categorical and other non-normal dependent variables. CABI.
  • Agresti, A. (2013). Categorical Data Analysis (3rd ed.). Wiley.