GLM vs GLMM: When Non-Normal Data Needs Plain Modeling and When It Needs Random Effects

    Non-normal responses—counts, binary outcomes, and strictly positive right-skewed values—break ordinary linear models. This article explains how the generalized linear model (GLM) and the generalized linear mixed model (GLMM) address different data structures, breaks down the three core components of a GLM (random component, systematic component, and link function), and shows why the independence assumption is the dividing line between the two. It provides a practical decision framework, walks through two classic examples (early-stage epidemic case counts and predator capture rates), and lists key modeling practices for matching distribution families and link functions to your data.

    1. Starting Point: Why GLM and GLMM Must Be Distinguished

    When building models in practice, we frequently encounter response variables that do not follow a normal distribution: daily new case counts in disease surveillance are count data, whether a customer clicks is a binary 0/1 outcome, and waiting times or incomes are continuous quantities that are strictly positive and right-skewed. Forcing an ordinary linear model (LM) onto such data produces biased estimates and invalid inference, because the distributional assumptions are wrong and the variance structure does not match.

    The generalized linear model (GLM) was created precisely to address this. It preserves the interpretable core of “linearity” while allowing the response variable to follow a broader family of distributions. The generalized linear mixed model (GLMM) goes one step further on top of the GLM to handle the problem of “non-independent data.” The two are not simple substitutes; they are two levels of tools for different data structures.

    The key to understanding GLM is to break it into three parts:

    1. Random component: the response variable $Y_i$ follows a distribution from the exponential family, such as Poisson, binomial, gamma, normal, and so on.
    2. Systematic component: a linear predictor $\eta_i = x_i\beta$ describes a linear combination of covariates, where $\beta$ is the vector of parameters to be estimated and $x_i$ is the $i$-th row of the design matrix $X$.
    3. Link function: a smooth, monotonic function $g(\cdot)$ that connects the response mean $\mu_i \equiv E(Y_i)$ to the linear predictor:

    $g(\mu_i) = \eta_i = x_i\beta$

    The most elegant feature of this structure is that no matter what distribution the response variable follows, as long as you choose the right link function, the parameters always enter the model in a “linear” way. This is the fundamental reason why so many ideas and concepts from linear modeling transfer seamlessly to the generalized case.

    Two boundaries are worth emphasizing:

    • When the link function is the identity function and the response follows a normal distribution, GLM naturally reduces to the ordinary linear model. In other words, the LM is a special case of the GLM.
    • GLM usually assumes that observations $Y_i$ are mutually independent. This “independence assumption” seems ordinary, but it is the key dividing line that separates GLM from GLMM.

    3. From GLM to GLMM: When the Independence Assumption Breaks Down

    Real-world data is often generated in groups. The same hospital, the same classroom, or the same subject observed repeatedly—individuals within a group are correlated. If we ignore this structure and treat all observations as mutually independent, standard errors are severely underestimated and significance conclusions can be completely distorted.

    The relationship between GLMM and the linear mixed model is exactly analogous to the relationship between GLM and the ordinary linear model. GLMM additionally introduces a random effect $u$ into the linear predictor:

    $\eta_i = x_i\beta + z_i u$

    Here $z_i u$ captures the within-group variation introduced by grouping or repeated measurements. This brings three benefits:

    • Correctly characterizes within-group correlation, yielding trustworthy standard errors and inference;
    • Supports partial pooling, staying robust even for groups with small samples;
    • Absorbs extra variation through random effects, mitigating overdispersion.

    4. A Practical Framework for Choosing Between Them

    For a concrete task, decide in the following order:

    1. First, look at the response distribution: is it count, proportion, or strictly positive right-skewed data, or some other non-normal data? If so, GLM is already required.
    2. Next, look at the data source structure: are observations grouped, nested, or longitudinally repeated? Is there obvious clustering, such as multiple centers or multiple batches?
    3. Finally, look at the degree of dispersion: if a Poisson or binomial model still cannot explain the excess variation in the data (overdispersion), random effects are often the better choice rather than patching things at the fixed-effects level.

    In one sentence: observations are mutually independent and the response is non-normal → GLM; observations show grouped correlation and the response is non-normal → GLMM.

    5. Two Classic Examples

    Example 1: New cases in the early stage of an epidemic. In the early phase of an outbreak, the number of new cases often grows approximately exponentially over time. Let $\mu_i$ be the expected number of new cases on day $t_i$; then:

    $\mu_i = \gamma \cdot e^{\delta t_i}$

    Taking the logarithm of both sides:

    $\log(\mu_i) = \log(\gamma) + t_i\delta = \beta_0 + t_i\beta_1$

    The parameters $\beta_0, \beta_1$ enter the right-hand side in a linear way. Since the response is a count, we choose the Poisson distribution; the overall model is a GLM of “Poisson response + log link + linear predictor.” Here the log link “straightens” the multiplicative exponential growth into an additive relationship.

    Example 2: The prey capture rate of a predator. The capture rate $y_i$ rises with prey density $x_i$, but saturates because of the predator’s upper limit on handling capacity:

    $y_i = \frac{\alpha x_i}{h + x_i}$

    where $\alpha$ is the maximum capture rate and $h$ is the prey density at which half of the maximum capture rate is reached. This expression is nonlinear in its parameters, but it can be linearized using a reciprocal link:

    $\frac{1}{\mu_i} = \frac{1}{\alpha} + \frac{h}{\alpha}\cdot\frac{1}{x_i}$

    After the transformation, the right-hand side becomes linear in the parameters again. This trick shares the same origin as the double-reciprocal transformation in enzyme kinetics, and it embodies the core idea of GLM: “digesting nonlinearity through the link function.”

    6. Key Modeling Practices

    • The choice of link function should be driven by the data-generating mechanism, not by blind trial and error: a log link for counts, a logit link for proportions, and a log or reciprocal link for strictly positive right-skewed data are common starting points.
    • The distribution family should match the response’s range and its variance-mean relationship: Poisson for counts, binomial for the number of successes/failures, and gamma for strictly positive continuous quantities.
    • When deciding whether a GLMM is needed, always explore whether the data has a grouping structure first, to avoid treating correlated data as independent.
    • Convergence and identifiability matter too: when the random-effects specification is too complex, the model may struggle to converge, so start simple and expand step by step.

    In summary, the distinction between GLM and GLMM is essentially a joint judgment over two dimensions: the response distribution and observation independence. Mastering the unified perspective of starting from the linear predictor and using a link function to connect the mean with covariates lets you make a clear and robust choice between the two.