Two-Way Tables

Analyze data in two-way tables

Two-Way Tables

How do you organize data with two categories? Two-way tables (also called contingency tables) help you analyze relationships between categorical variables! They're essential for comparing groups, finding patterns, and making data-driven decisions.


What Is a Two-Way Table?

A two-way table organizes data by two categorical variables.

Structure:

  • Rows: One categorical variable
  • Columns: Another categorical variable
  • Cells: Frequency or count for each combination
  • Totals: Row totals, column totals, grand total

Also called:

  • Contingency table
  • Cross-tabulation
  • Frequency table

Reading a Two-Way Table

Example: Survey of 100 students about pets and grades

| | Cat | Dog | No Pet | Row Total | |---|-----|-----|--------|-----------| | A Grade | 15 | 20 | 10 | 45 | | B Grade | 10 | 15 | 8 | 33 | | C Grade | 5 | 10 | 7 | 22 | | Column Total | 30 | 45 | 25 | 100 |

Reading the table:

  • 15 students have cats AND A grades
  • 20 students have dogs AND A grades
  • 45 students total have A grades
  • 30 students total have cats
  • Grand total: 100 students

Row Totals and Column Totals

Row totals:

  • Sum of all values in that row
  • Represents total for one category

Column totals:

  • Sum of all values in that column
  • Represents total for other category

Grand total:

  • Sum of all cells
  • Sum of all row totals
  • Sum of all column totals
  • Total number of data points

Check: Row totals should sum to grand total! Check: Column totals should sum to grand total!


Joint Frequencies

Joint frequency = count in a specific cell

Represents both categories together.

Example: From the pet table

  • 15 students have BOTH a cat AND an A grade
  • This is a joint frequency

Symbol: Often just the number in the cell


Marginal Frequencies

Marginal frequency = row total or column total

Found in the "margins" of the table.

Example: From the pet table

  • 45 students have A grades (row total)
  • 30 students have cats (column total)
  • These are marginal frequencies

Why "marginal"?

  • They appear in the margins (edges) of the table
  • They show totals for just ONE variable

Calculating Frequencies

Example: Create a two-way table from data

Survey: 50 students asked about favorite subject (Math/English) and grade level (7th/8th)

Raw data:

  • 15 seventh-graders like Math
  • 10 seventh-graders like English
  • 12 eighth-graders like Math
  • 13 eighth-graders like English

Create table:

| | Math | English | Row Total | |---|------|---------|-----------| | 7th Grade | 15 | 10 | 25 | | 8th Grade | 12 | 13 | 25 | | Column Total | 27 | 23 | 50 |

Check:

  • Row totals: 25 + 25 = 50 โœ“
  • Column totals: 27 + 23 = 50 โœ“

Relative Frequency

Relative frequency = frequency รท total (expressed as fraction, decimal, or percent)

Shows proportion or percentage.

Types:

Joint relative frequency: (Cell value) รท (Grand total)

Marginal relative frequency: (Row or column total) รท (Grand total)

Conditional relative frequency: We'll discuss this next!


Calculating Relative Frequencies

Example: Using the pet table (grand total = 100)

Joint relative frequency for "Cat and A grade": 15/100 = 0.15 = 15%

Marginal relative frequency for "A grade": 45/100 = 0.45 = 45%

Marginal relative frequency for "Cat": 30/100 = 0.30 = 30%

Interpretation:

  • 15% of all students have a cat AND an A grade
  • 45% of all students have an A grade
  • 30% of all students have a cat

Conditional Relative Frequency

Conditional relative frequency answers: "What percent of THIS group has THAT characteristic?"

Formula: (Specific cell) รท (Row or column total)

Two types:

1. Given the row: What percent of [row category] are in [column category]?

2. Given the column: What percent of [column category] are in [row category]?


Examples of Conditional Relative Frequency

Using pet table:

Question 1: What percent of A-grade students have cats?

Solution: Given: A-grade students (row) Find: Those with cats

Conditional frequency = 15/45 = 1/3 โ‰ˆ 0.333 = 33.3%

Answer: 33.3% of A-grade students have cats

Question 2: What percent of cat owners have A grades?

Solution: Given: Cat owners (column) Find: Those with A grades

Conditional frequency = 15/30 = 1/2 = 0.50 = 50%

Answer: 50% of cat owners have A grades

Note: These are DIFFERENT questions with different answers!


Conditional Relative Frequency Table

You can create a whole table of conditional relative frequencies!

Example: Percent within each grade level

| | Cat | Dog | No Pet | Row Total | |---|-----|-----|--------|-----------| | A Grade | 33% | 44% | 22% | 100% | | B Grade | 30% | 45% | 24% | 100% | | C Grade | 23% | 45% | 32% | 100% |

Each row sums to 100%

Calculations:

  • A grade, Cat: 15/45 โ‰ˆ 33%
  • A grade, Dog: 20/45 โ‰ˆ 44%
  • A grade, No Pet: 10/45 โ‰ˆ 22%

This shows distribution WITHIN each grade level


Using Two-Way Tables for Analysis

Looking for associations:

Do two variables seem related?

Example: Pet ownership and grades

Compare conditional frequencies:

  • A-grade cat owners: 33%
  • B-grade cat owners: 30%
  • C-grade cat owners: 23%

Observation: A-grade students more likely to have cats Question: Is this association significant or just random variation?


Real-World Applications

Marketing:

  • Customer age vs. product preference
  • Location vs. buying habits
  • Gender vs. brand loyalty

Medicine:

  • Treatment vs. outcome
  • Age group vs. symptoms
  • Exposure vs. disease occurrence

Education:

  • Study method vs. test results
  • Attendance vs. grades
  • Homework completion vs. understanding

Sports:

  • Position vs. injury type
  • Training method vs. performance
  • Home vs. away game results

Social Science:

  • Gender vs. career choice
  • Age vs. voting preference
  • Income level vs. education

Example Problem

Survey of 200 people: Exercise frequency and health rating

| | Healthy | Average | Poor | Row Total | |---|---------|---------|------|-----------| | Daily Exercise | 45 | 20 | 5 | 70 | | Weekly Exercise | 30 | 35 | 15 | 80 | | Rarely Exercise | 10 | 25 | 15 | 50 | | Column Total | 85 | 80 | 35 | 200 |

Questions:

a) What percent of people exercise daily? 70/200 = 0.35 = 35%

b) What percent of people rate themselves as healthy? 85/200 = 0.425 = 42.5%

c) What percent of daily exercisers rate themselves as healthy? 45/70 โ‰ˆ 0.643 = 64.3%

d) What percent of healthy people exercise daily? 45/85 โ‰ˆ 0.529 = 52.9%

e) Is there an association between exercise and health rating? Yes! Daily exercisers have higher healthy rating (64.3%) than rare exercisers (10/50 = 20%)


Creating Two-Way Tables from Data

Steps:

  1. Identify the two categorical variables
  2. Determine categories for each variable
  3. Set up table structure (rows and columns)
  4. Count frequencies for each combination
  5. Calculate row totals
  6. Calculate column totals
  7. Find grand total
  8. Verify totals match!

Example: Survey data - 20 students, gender and sport preference

Data: M-Soccer, F-Soccer, M-Basketball, F-Basketball, M-Soccer, F-Soccer, M-Basketball, F-Soccer, M-Soccer, F-Basketball, M-Basketball, F-Soccer, M-Soccer, F-Basketball, M-Soccer, F-Soccer, M-Basketball, F-Basketball, M-Soccer, F-Soccer

Count:

  • M-Soccer: 7
  • M-Basketball: 4
  • F-Soccer: 6
  • F-Basketball: 3

Table:

| | Soccer | Basketball | Row Total | |---|--------|-----------|-----------| | Male | 7 | 4 | 11 | | Female | 6 | 3 | 9 | | Column Total | 13 | 7 | 20 |


Common Mistakes to Avoid

โŒ Mistake 1: Confusing joint and conditional frequencies

  • Joint: part of whole (รท grand total)
  • Conditional: part of subgroup (รท row or column total)

โŒ Mistake 2: Using wrong total for conditional frequency

  • Make sure you divide by the RIGHT total!
  • Given row? Use row total.
  • Given column? Use column total.

โŒ Mistake 3: Forgetting to check totals

  • Row totals should sum to grand total
  • Column totals should sum to grand total

โŒ Mistake 4: Mixing up rows and columns

  • "Percent of A that are B" vs. "Percent of B that are A"
  • These are different!

โŒ Mistake 5: Not converting to percents when asked

  • If question asks for percent, don't leave as fraction!
  • Multiply by 100 and add % sign

Problem-Solving Strategy

Reading tables:

  1. Identify what each row represents
  2. Identify what each column represents
  3. Find the relevant cell or total
  4. Interpret in context

Calculating frequencies:

  1. Identify what type: joint, marginal, or conditional
  2. Find numerator (cell value or total)
  3. Find denominator (grand total or row/column total)
  4. Calculate and express as requested (fraction, decimal, percent)

Analyzing relationships:

  1. Calculate conditional frequencies for comparison
  2. Look for notable differences
  3. Consider whether association exists
  4. State conclusion in context

Quick Reference

Parts of Two-Way Table:

  • Rows: One categorical variable
  • Columns: Other categorical variable
  • Cells: Frequency counts
  • Row totals: Marginal frequencies (rows)
  • Column totals: Marginal frequencies (columns)
  • Grand total: Total number of observations

Types of Frequencies:

Joint frequency: Count in a specific cell

Marginal frequency: Row total or column total

Joint relative frequency: (Cell value) รท (Grand total)

Marginal relative frequency: (Row or column total) รท (Grand total)

Conditional relative frequency: (Cell value) รท (Row or column total)


Practice Tips

Tip 1: Always verify totals

  • Quick check for accuracy
  • Catches arithmetic errors

Tip 2: Read questions carefully

  • "Of A" vs. "of B" matters!
  • Determines which total to use

Tip 3: Use labels

  • Keep track of what each number represents
  • Write out calculations clearly

Tip 4: Think about context

  • Do the numbers make sense?
  • Does the pattern seem reasonable?

Tip 5: Practice both directions

  • Given row, find column percent
  • Given column, find row percent

Summary

Two-way tables organize data with two categorical variables:

Structure:

  • Rows and columns for categories
  • Cells show frequency counts
  • Marginal totals in margins
  • Grand total in corner

Types of frequencies:

  • Joint: specific cell (both categories)
  • Marginal: row or column total (one category)
  • Conditional: within a specific group

Relative frequencies:

  • Express as fraction, decimal, or percent
  • Divide by appropriate total
  • Useful for comparisons

Applications:

  • Identify associations between variables
  • Compare groups
  • Make data-driven decisions
  • Analyze patterns in categorical data

Two-way tables are powerful tools for organizing, analyzing, and interpreting categorical data in countless real-world situations!

๐Ÿ“š Practice Problems

1Problem 1easy

โ“ Question:

A survey of 100 students shows: 30 like math, 50 like science, 20 like both. How many like neither?

๐Ÿ’ก Show Solution

Students liking math OR science = 30 + 50 - 20 = 60

(We subtract 20 because those who like both were counted twice)

Students liking neither = 100 - 60 = 40

Answer: 40 students

2Problem 2easy

โ“ Question:

In a two-way table, 25 out of 50 boys play sports and 30 out of 60 girls play sports. What is the joint frequency for girls who play sports?

๐Ÿ’ก Show Solution

Joint frequency is the count in a specific cell.

Girls who play sports = 30

Answer: 30

3Problem 3medium

โ“ Question:

A table shows: 40 adults prefer coffee, 60 prefer tea (100 total adults); 30 teens prefer coffee, 20 prefer tea (50 total teens). What percent of ALL people prefer coffee?

๐Ÿ’ก Show Solution

Total preferring coffee = 40 + 30 = 70

Grand total = 100 + 50 = 150

Percent = 70/150 = 7/15 โ‰ˆ 0.467 = 46.7%

Answer: 46.7% (or 7/15)

4Problem 4medium

โ“ Question:

Using the table from the previous problem, what percent of adults prefer coffee?

๐Ÿ’ก Show Solution

This is CONDITIONAL relative frequency (given adults).

Adults preferring coffee = 40 Total adults = 100

Percent = 40/100 = 0.40 = 40%

Answer: 40%

5Problem 5hard

โ“ Question:

A study shows: Of 80 people who exercise daily, 60 rate their health as good. Of 120 people who rarely exercise, 40 rate their health as good. Is there an association between exercise and health rating?

๐Ÿ’ก Show Solution

Compare conditional frequencies:

Daily exercisers with good health: 60/80 = 75%

Rare exercisers with good health: 40/120 = 33.3%

Large difference (75% vs 33.3%) suggests an association.

People who exercise daily are more likely to rate their health as good.

Answer: Yes, there appears to be a positive association between daily exercise and good health ratings