Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 34

Choosing Between Contingency Tables and GLMs

Recommended resources

Hello! Welcome to the final module of your crash course. In the previous lessons, we've built a strong foundation in specific analytical techniques, culminating in how to assess the goodness-of-fit for a logistic regression model.

Now, it's time to bring everything together. This module is all about exam strategy and application. The most critical skill for your exam is to look at a problem description and quickly and confidently decide which statistical tool is the right one for the job.

Today's lesson addresses this head-on. Our learning outcome is to: Given a problem description, decide whether a contingency table analysis or a GLM is the more appropriate method. We will create a clear, step-by-step decision framework that you can apply under exam pressure.

Let's begin.

1. The Core Distinction: Association vs. Prediction

At the highest level, the choice between contingency table analysis and a Generalized Linear Model (GLM) like logistic regression comes down to the research question.

  • Contingency Table Analysis (Chi-square, Fisher's Exact Test): This approach is designed to answer one primary question: Is there a statistically significant association between two categorical variables? It tests for independence. For example: "Is there an association between a person's region (North, South, East, West) and their preferred brand of coffee (A, B, C)?"

  • Generalized Linear Models (e.g., Logistic Regression): This is a more powerful and flexible framework for modeling and predicting an outcome. It allows you to understand how one or more predictor variables (which can be categorical or continuous) affect a categorical outcome. Crucially, it lets you assess the impact of one variable while controlling for the effects of others. For example: "Can we predict the likelihood of a person buying Brand A coffee based on their region, age, and income?"

The need to control for other variables, often called confounders, is one of the most common reasons to choose a GLM over a simple contingency table analysis.


2. A Practical Thought Process

To see how this decision process works in practice, let's watch a short video. The presenter is given a scenario and must choose the correct statistical test from a list. Pay close attention to how they use the variable types to eliminate incorrect options.

USMLE Step 1 | How to Choose the Correct Statistical Test

This video, 'How to Choose the Correct Statistical Test' from MedSchoolCoach, provides an excellent example of the elimination process you should use on an exam.

Watch the video from the beginning until 07:23. Focus on these key steps in the narrator's logic: Identify the variables: The problem involves a treatment group (categorical predictor) and levels of nausea (categorical outcome). Eliminate tests for continuous outcomes: Notice how ANOVA and t-tests are immediately ruled out because the outcome (nausea level) is not continuous. Eliminate tests based on predictor count: See how multiple regression is discussed but deemed less appropriate for a single predictor model. Select the appropriate test for categorical data: The video correctly lands on the Chi-square test because it is designed to compare two categorical variables.

The video demonstrates the first step in any analysis: understanding your variables and the basic question. Now, let's formalize this into a robust framework.


3. A Formal Decision Framework

The best way to decide on a method is to consider the structure of your data and your analytical goals. A fantastic resource for this comes from a set of course notes by Dr. Pascal Tyrrell.

Chapter 5 Categorical Data Analysis

The following PDF, 'Chapter 5 Categorical Data Analysis', contains a clear and concise decision table that we will use as the core of our strategy.

Please open the document and go to slide 19 (labeled as page 5-18). Find the table titled 'Overview'. This table is your key decision-making tool. Focus on the row where the 'Type of Response' is Categorical. Then, briefly look at the introduction to logistic regression on slides 56-59 to see how it's presented as an alternative to linear regression for categorical outcomes.

Let's summarize the key insight from that table for a categorical response variable:

Type of Predictors Type of Response Analysis Method
Categorical Categorical Contingency Table Analysis or Logistic Regression
Continuous Categorical Logistic Regression
Continuous and Categorical Categorical Logistic Regression

This table makes our decision very clear in two out of three cases:

  • If you have any continuous predictors, you must use a GLM (Logistic Regression). Contingency tables are only for categorical variables.

This leaves one ambiguous case: What if both your predictor and response variables are categorical? This is where we need to look closer at the goal of the analysis.


4. Resolving the Ambiguity: Confounders and Multiple Predictors

When all your variables are categorical, the choice between contingency table analysis and logistic regression depends on the complexity of your question.

A contingency table is perfect for analyzing the relationship between two categorical variables. But what if you have more than two, or you suspect another variable is influencing the relationship? This is the limitation of basic contingency table analysis.

The following resource explains this limitation and motivates the move to logistic regression.

Topics in Biostatistics Categorical Data Analysis and Logistic ...

This document by B. Rosner explicitly discusses the limitations of contingency table analysis and why regression models are often necessary.

Please read two short sections: 'Limitations of contingency table analysis' (slides 51-52): This section explains that while you can stratify contingency tables to handle a confounding variable, a regression model is a better approach for controlling for confounders. 'Summary' (slides 88-89): This provides a final, direct comparison of when to use chi-square methods versus logistic regression. Points 3 and 4 are especially relevant.

As the resource highlights, logistic regression extends the capabilities of chi-square methods. It allows you to:

  1. Model an outcome based on multiple predictor variables simultaneously.
  2. Control for confounding variables, isolating the effect of your primary predictor of interest.
  3. Handle both categorical and continuous predictors in the same model.

5. Your Exam Strategy: A Decision Flowchart

Let's synthesize this into a step-by-step process you can use to analyze any exam problem.


Decision Flowchart: Contingency Table vs. GLM

When you read a problem, ask yourself these questions in order:

  1. What is the OUTCOME (response) variable and what is its type?

    • If it's continuous, neither method is right. You'd likely use linear regression.
    • If it's categorical, proceed to the next step.
  2. How many PREDICTOR (explanatory) variables are there?

    • If there is MORE THAN ONE predictor, your choice is clear: Use a GLM (Logistic Regression). This is the only way to model their combined influence.
    • If there is only ONE predictor, proceed to the next step.
  3. With one predictor, what is its type?

    • If the predictor is continuous, you must Use a GLM (Logistic Regression). A contingency table requires categorical variables.
    • If the predictor is categorical, proceed to the final question.
  4. You have one categorical predictor and one categorical outcome. What is the goal?

    • Is the question asking you to test for an association, relationship, or independence between the two variables? Use Contingency Table Analysis (Chi-Square or Fisher's Test).
    • Is the question asking you to predict the outcome, model the probability of an outcome, or estimate an odds ratio while adjusting for other factors (even if those factors aren't in this specific model, this phrasing hints at a modeling approach)? Use a GLM (Logistic Regression). It provides a more robust modeling framework and directly estimates odds ratios.

The phrase "controlling for," "adjusting for," or "accounting for" is your strongest signal to use a GLM.



6. Worked Scenarios

Let's apply the flowchart to a few examples.

Scenario A:

A sociologist wants to determine if there is a relationship between marital status (Single, Married, Divorced, Widowed) and level of happiness (Not Happy, Moderately Happy, Very Happy) in a survey of 1,000 adults.

  • 1. Outcome: Happiness (Categorical). Proceed.
  • 2. Predictors: One predictor: Marital Status. Proceed.
  • 3. Predictor Type: Marital Status is Categorical. Proceed.
  • 4. Goal: The goal is to determine if there is a "relationship" (association).
  • Decision: Contingency Table Analysis.

Scenario B:

A hospital wants to predict the likelihood of patient readmission within 30 days. They have data on the patient's age (in years), length of initial hospital stay (in days), and whether they have a chronic condition (yes/no).

  • 1. Outcome: Readmission (Categorical: yes/no). Proceed.
  • 2. Predictors: Three predictors: age, length of stay, chronic condition.
  • Decision: GLM (Logistic Regression). There is more than one predictor.

Scenario C:

A political campaign wants to understand the effect of sending a specific mailer (yes/no) on the probability of a person voting, after adjusting for their income bracket.

  • 1. Outcome: Voting (Categorical: yes/no). Proceed.
  • 2. Predictors: Two predictors: Mailer status, Income bracket. The phrase "adjusting for" is the key.
  • Decision: GLM (Logistic Regression).

Conclusion

You now have a structured framework for making one of the most important high-level decisions in categorical data analysis.

Key Takeaways:

  • The choice between contingency table analysis and a GLM depends on the number and type of variables and the research goal.
  • Contingency table analysis is ideal for testing the association between two categorical variables.
  • GLMs (Logistic Regression) are necessary when you have:
    • Multiple predictors.
    • Any continuous predictors.
    • A need to control for confounding variables.

Preview of the Next Lesson:
In our next lesson, we will put this decision-making skill into practice. We will tackle full, exam-style application problems where you will first have to choose the correct method (chi-square or logistic regression) and then proceed to solve the problem and interpret the results.