Hello! Welcome to our penultimate lesson in this module on Poisson regression and log-linear models.
In our last session, we established a crucial conceptual link: the chi-square test of independence is a specific instance of comparing two log-linear models—the independence model and the saturated model. This reframed a classic statistical test within the broader, more powerful framework of Generalized Linear Models (GLMs).
Today, we will make that connection even more concrete. The main goal of this lesson is to show you that log-linear models are implemented using Poisson regression. By the end of our session, you will be able to explain exactly how a Poisson regression model, with cell counts as the response variable, is used to fit and analyze the association structures described by log-linear models.
1. A Quick Refresher: The Poisson Regression Model
Before we build the bridge to log-linear models, let's quickly recall the three components of a Poisson regression model, which we've designed specifically for count data.
Poisson regression - clearly explained
This short clip from the 'Poisson regression - clearly explained' video provides a concise summary of the three components of a Poisson GLM.
Please watch the segment from 06:29 to 08:30. Pay close attention to how it defines the three key components: the probability function, the linear predictor, and the link function.
As the video explained, a Poisson regression model is a GLM with:
- Random Component: The response variable (the counts) is assumed to follow a Poisson distribution.
- Systematic Component: A linear predictor, which is a linear combination of the predictor variables (e.g., ).
- Link Function: A log link, which connects the expected value of the response to the linear predictor: .
Keep these three components in mind as we now connect them to log-linear models.
2. The Core Connection: Fitting Log-Linear Models with Poisson Regression
Here is the central idea that unites these two concepts:
To fit a log-linear model to a contingency table, we treat the cell counts as the response variable in a Poisson regression. The categorical variables that define the rows and columns of the table become the predictor variables.
This works because the fundamental assumption of a log-linear model is that the count in each cell, , is an independent observation from a Poisson distribution with a mean .
Let's break this down. Consider a simple 2x2 contingency table:
| Variable B (B1) | Variable B (B2) | |
|---|---|---|
| Variable A (A1) | ||
| Variable A (A2) |
To analyze this with a GLM, we first restructure the data from a wide table format into a "long" format:
| Count | VarA | VarB |
|---|---|---|
| A1 | B1 | |
| A1 | B2 | |
| A2 | B1 | |
| A2 | B2 |
Now, look what happens when we fit a Poisson regression to this long-format data, with Count as the response:glm(Count ~ VarA + VarB, family = poisson(link="log"))
The underlying model for this is:
This is precisely the log-linear model of independence, just written in regression notation!
Similarly, if we fit the saturated model using Poisson regression:glm(Count ~ VarA * VarB, family = poisson(link="log"))
The underlying model includes an interaction term:
This corresponds exactly to the saturated log-linear model:
The following reading from Penn State's STAT 504 course makes this connection explicit and shows how it's done in both R and SAS.
10 Log-Linear Models – STAT 504 | Analysis of Discrete Data
This resource directly confirms the connection we've just discussed. It states the Poisson assumption and then demonstrates how to use GLM software (specifically for Poisson regression) to fit log-linear models.
Please read the following three short sections: Start at the heading 'Model Structure' within '10.1 Log-Linear Models for Two-way Tables'. Pay close attention to the 'Model Assumptions' paragraph, which states that cell counts are assumed to be from a Poisson random variable. Read the section 'The PROC GENMOD procedure'. Notice the code dist=poisson link=log. This tells the software to fit a Poisson regression model. Read the section 'The LOGLIN and GLM functions in R'. Notice the code glm(..., family=poisson()). This is R's function for fitting a GLM, and family=poisson() specifies it as a Poisson regression. \nFocus on how both software implementations use a Poisson model to fit the log-linear structure.
3. The Power of the Connection: Analyzing Multi-way Tables
The true power of this framework becomes apparent when we move beyond simple 2x2 tables to multi-way tables (e.g., 2x2x3). While a single chi-square test can tell you if there's some association present, it can't describe the complex relationships (like conditional independence or homogeneous association) that might exist.
By using Poisson regression, we can fit and compare various log-linear models to test specific hypotheses about these complex associations.
For a three-way table with variables A, B, and C, we can test different models by simply changing the formula in our glm() call:
- Complete Independence (A, B, C):
glm(Count ~ A + B + C, family=poisson) - Conditional Independence of A and B given C ((AC, BC)):
glm(Count ~ A*C + B*C, family=poisson) - Homogeneous Association (AB, AC, BC):
glm(Count ~ A*B + A*C + B*C, family=poisson) - Saturated Model (ABC):
glm(Count ~ A*B*C, family=poisson)
This provides a unified and highly flexible toolkit for dissecting the structure of contingency tables.
Chapter 7 Contingency Tables | ELMER: Extensions to the Linear ...
The following text demonstrates this flexibility with a real-world example of a three-way table, showing how different log-linear models correspond to different GLM formulas.
Please read from the beginning of the chapter until the end of section '7.3.2 Types of model'. In the introductory part, focus on the key sentence: 'In all cases mentioned, so long as the totals in the margin are treated as given, the likelihood function is identical to that of a GLM with the counts in each cell having a Poisson distribution with a log link function.' In section '7.3.2 Types of model', see how different models of association (e.g., [12][3], [12][13]) are described. These correspond directly to the different glm() formulas we discussed above.
This approach transforms contingency table analysis from a series of specific, isolated tests into a comprehensive modeling activity, which is much more aligned with the modern data science workflow.
Conclusion
In this lesson, we solidified the final link in the chain connecting classical contingency table analysis to the modern GLM framework. We saw that the conceptual log-linear models we've been discussing are not just theoretical—they are practically fitted using Poisson regression.
Key Takeaways:
- Log-linear models and Poisson regression are intrinsically connected. A log-linear model is a Poisson regression model applied to contingency table counts.
- The core idea is to treat the cell counts as the response variable and the categorical variables defining the table as the predictor variables.
- The fundamental assumption is that cell counts are independent observations from a Poisson distribution.
- The log-linear model equation (e.g., ) is precisely what is estimated by a
glm()function withfamily=poissonand aloglink. - This connection provides a powerful, unified, and flexible method for analyzing complex, multi-way contingency tables by fitting and comparing different regression models.
Preview of the Next Lesson:
This concludes the theoretical part of our module on log-linear models. In our final lesson, we will put all these pieces together in a practical application. We will take a multi-way contingency table, use Poisson regression to fit various log-linear models, and interpret the results to understand the association structure within the data.