How do you explore two categorical variables, and what does a contingency table tell you?

Quick Overview

Asks how to explore the relationship between two categorical variables and what a contingency table reveals about them. Tests conditional proportions, the chi-square test of independence, effect size, and the pitfalls of sparse cells and confounders.

How do you explore two categorical variables, and what does a contingency table tell you?

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Other

How would you explore the relationship between two categorical variables, and what does a contingency table or cross-tabulation tell you? ```hint Compare like with like Raw counts depend on how large each group is. Think about what you would divide by before comparing one group with another. ``` ### What a Strong Answer Covers - What the cells and margins of a contingency table hold, and how to build one. - How conditional proportions show whether one variable's distribution changes across the levels of the other. - Charts suited to comparing composition across groups. - A formal test of independence and a measure of strength, with the caveats about sparse cells and large samples. ### Follow-up Questions - The chi-square test is highly significant but Cramer's V is 0.05. How do you report that result? - Several cells have expected counts below 5. What do you do? - The association between device and conversion reverses once you split the data by country. What is going on, and how do you analyze it? - One of the variables has 200 levels. How do you make the table readable without hiding real structure?

Overview: Asks how to explore the relationship between two categorical variables and what a contingency table reveals about them. Tests conditional proportions, the chi-square test of independence, effect size, and the pitfalls of sparse cells and confounders.

Nov 25, 2026
mediumData ScientistOtherData Manipulation (SQL/Python)
0
0

How would you explore the relationship between two categorical variables, and what does a contingency table or cross-tabulation tell you?

What a Strong Answer Covers Guidance

  • What the cells and margins of a contingency table hold, and how to build one.
  • How conditional proportions show whether one variable's distribution changes across the levels of the other.
  • Charts suited to comparing composition across groups.
  • A formal test of independence and a measure of strength, with the caveats about sparse cells and large samples.

Follow-up Questions Guidance

  • The chi-square test is highly significant but Cramer's V is 0.05. How do you report that result?
  • Several cells have expected counts below 5. What do you do?
  • The association between device and conversion reverses once you split the data by country. What is going on, and how do you analyze it?
  • One of the variables has 200 levels. How do you make the table readable without hiding real structure?