Applied Regression Analysis for Empirical Research: Inference, Causality, and Model Choice with GLMMs in R

Author
Published

June 1, 2026

Preface

Statistics is about extracting the underlying truth from data. In their book, Hilborn and Mangel (1997) compare this process to the work of a detective. If you are to become such a detective, you will have to think logically and apply common sense. Every study and dataset is different, and no textbook or flowchart can save you from the infinite number of possible errors or complications that can occur in a real study. However, there are also some general patterns and techniques that will help you with the process of understanding data. One of these is regression models, which is the topic of this book.

Hilborn, R. and Mangel, M. (1997) The ecological detective: Confronting models with data. Princeton, NJ: Princeton University Press (Monographs in population biology, 28).

Overview and organization of this book

Generalized (linear) mixed models are a framework for modeling a wide range of data structures. They can be applied if we have a response variable (also called dependent variable) and want to understand how this response variable is influenced by one or several predictors (also called independent variables or explanatory variables). The aim of this book is to introduce you to this framework, and to give guidance on its use in the quality expected for a “real” scientific study. It is organized in three main parts, followed by a workflow chapter (12  From question to paper: the analysis workflow) and appendices (quick reference, Appendix B — Quick reference; case studies, Appendix C — Case studies):

  1. Modeling the mean: The first part of this book focuses on how to model the mean response as a function of one or several predictor variables. In this part, we mainly work with normally distributed residuals with constant variance; mixed models additionally relax the independence of the residuals, and nonlinear regression the linear form of the mean. Topics we will cover here are linear regression (2  Linear Regression), ANOVA (3  ANOVA and other tests on the LM), mixed models (4  Linear mixed models) and nonlinear regression (5  Nonlinear regressions).
  2. Model choice: The second part covers model choice, including how to handle missing data (6  Missing data), causal inference (7  Causal inference) and model selection (8  Model selection), with cross-validation (Cross-validation).
  3. Modeling the distribution: The third part of the book is about modeling different residual distributions. We will relax the iid normal assumptions of the LM, and move to GLMs (9  GL(M)Ms) and modeling variance (10  Dispersion models) and correlation (11  Correlation structures) of residuals.

The analysis workflow

In a real scientific project (or, to stay with the analogy of our detective - in a real murder investigation), these techniques will (re)appear in several steps along the way. The usual workflow of a scientific analysis is:

  1. Question and goal: causal, predictive or exploratory?
  2. Design and data: experimental unit, grouping, data checks and missing values
  3. A-priori model: distribution, predictors, random effects and correlation structures
  4. Fit the model
  5. Check residuals and adjust the model
  6. Inference: tests, confidence intervals and predictions
  7. Report the analysis

The workflow chapter at the end of the book (12  From question to paper: the analysis workflow) goes through these steps in detail, with pointers to the chapters that are relevant for each step. In the chapters, a line “Workflow steps” at the start tells you which steps the chapter supports.

Inferential philosophy and scope

This book uses frequentist (maximum likelihood) estimation, with only brief Bayesian (brms) examples. My companion book on Bayesian statistics (Hartig, 2024) covers the Bayesian approach to these models, as well as hierarchical models that go beyond GLMMs (see Next steps). Some other response types that are common in ecology, such as ordinal responses and survival (time-to-event) data, are only mentioned briefly in this book.

Hartig, F. (2024) “Introduction to Bayesian statistics with R.” Available at: https://florianhartig.github.io/LearningBayes/.

Assumed knowledge

This book assumes basic prior knowledge of statistical methods (tests, regressions, p-value, power, CIs, …) and the ability to apply those in R. At the University of Regensburg, this knowledge would be taught in the Bachelor’s biology lecture “Statistik und Bioinformatik” (lecture notes in German here), and the block course “Introduction to statistics in R”. If you didn’t take those or comparable courses, you should at least try to get some basic understanding of R before proceeding with this book. This lecture series from MarinStatsLectures could be a good start. The first chapter of this book (1  Getting Started) lists some of the basic R knowledge that is assumed (Assumed R knowledge), but it doesn’t cover the theoretical basics such as p-values, CIs and so on that you should also have.

Feedback and licencing

If you have comments, questions or suggestions regarding this book, please submit them here.

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Note that some elements of this work (embedded videos, graphics) may be under a separate license and are thus not included in this license.

Creative Commons License