Solved Exercises on Two-Way Frequency Tables

Master two-way tables: joint, marginal, and conditional frequencies through these 5 detailed exercises covering construction, analysis, and interpretation of contingency tables.

Solution: Exercises 1 to 3
1 Basic Two-Way Table Construction
Exercise 1
A survey of 200 students asked about their favorite subject (Math or English) and grade level (Freshman or Sophomore). The results are: 60 Freshmen prefer Math, 40 prefer English; 70 Sophomores prefer Math, 30 prefer English. Create a two-way frequency table and find the marginal frequencies.
Definition:

Two-way frequency table: A table that displays the frequency of data points for two categorical variables.

Joint frequency: The count of observations that fall into a specific combination of categories.

Marginal frequency: The total count for each category across the other variable.

Table construction method:
  1. Identify the two categorical variables
  2. Create rows for one variable and columns for the other
  3. Fill in the joint frequencies
  4. Calculate row totals and column totals
  5. Verify that grand total matches sample size
Step 1: Identify variables

Variable 1: Grade level (Freshman, Sophomore)

Variable 2: Favorite subject (Math, English)

Step 2: Create the table structure
Favorite Subject Math English Total
Freshman 60 40 100
Sophomore 70 30 100
Total 130 70 200
Step 3: Identify joint frequencies

Freshmen who prefer Math: 60 (joint frequency)

Freshmen who prefer English: 40 (joint frequency)

Sophomores who prefer Math: 70 (joint frequency)

Sophomores who prefer English: 30 (joint frequency)

Step 4: Calculate marginal frequencies

Row marginals (grade totals):

• Freshmen total: 60 + 40 = 100

• Sophomores total: 70 + 30 = 100

Column marginals (subject totals):

• Math total: 60 + 70 = 130

• English total: 40 + 30 = 70

Step 5: Verify the grand total

Sum of all joint frequencies: 60 + 40 + 70 + 30 = 200

Grand total from row/column: 100 + 100 = 200 or 130 + 70 = 200

✓ Verification confirms table is correct

Table completed with joint frequencies (60, 40, 70, 30) and marginal totals (100, 100, 130, 70)
Final answer:

The two-way table shows joint frequencies of student preferences by grade level. Marginal frequencies show that there are 100 freshmen and 100 sophomores, with 130 preferring Math and 70 preferring English. The most popular combination is Sophomore + Math (70 students).

Applied rules:

• Joint frequencies: Internal cells of the table

• Marginal frequencies: Row and column totals

• Grand total: Sum of all joint frequencies

2 Conditional Frequency Analysis
Exercise 2
Using the table from Exercise 1, find the conditional frequency of preferring Math given that a student is a Sophomore. Also find the conditional frequency of being a Sophomore given that a student prefers English.
Definition:

Conditional frequency: The frequency of one variable given that another variable takes a specific value.

Conditional relative frequency: The conditional frequency divided by the relevant marginal total.

Step 1: Recall the table from Exercise 1
Favorite Subject Math English Total
Freshman 60 40 100
Sophomore 70 30 100
Total 130 70 200
Step 2: Find P(Math | Sophomore)

Formula: P(A|B) = P(A and B) ÷ P(B)

In terms of frequencies: P(Math | Sophomore) = Joint frequency (Sophomore and Math) ÷ Marginal frequency (Sophomore)

P(Math | Sophomore) = 70 ÷ 100 = 0.70 or 70%

Step 3: Find P(Sophomore | English)

P(Sophomore | English) = Joint frequency (Sophomore and English) ÷ Marginal frequency (English)

P(Sophomore | English) = 30 ÷ 70 = 0.429 or 42.9%

Step 4: Interpret the results

Given a student is a Sophomore, there's a 70% chance they prefer Math

Given a student prefers English, there's a 42.9% chance they are a Sophomore

Step 5: Compare with unconditional probabilities

Unconditional P(Math) = 130/200 = 0.65

Conditional P(Math | Sophomore) = 0.70

Sophomores are more likely to prefer Math than the general population

P(Math | Sophomore) = 0.70; P(Sophomore | English) = 0.429
Final answer:

The conditional probability of preferring Math given Sophomore status is 70%. The conditional probability of being a Sophomore given English preference is 42.9%. This shows that Sophomores are more likely to prefer Math than the general student population (65% vs 70%).

Applied rules:

• Conditional probability: P(A|B) = P(A ∩ B) ÷ P(B)

• Frequency version: Joint frequency ÷ Relevant marginal frequency

• Interpretation: Probability within a specific subgroup

3 Association and Independence
Exercise 3
Determine if grade level and favorite subject are independent using the data from Exercise 1. What does independence mean in this context?
Definition:

Independence: Two variables are independent if knowing the value of one variable provides no information about the value of the other variable.

Association: Two variables are associated if there's a relationship between their values.

Step 1: State the independence condition

Variables are independent if: P(A|B) = P(A) for all combinations

Or equivalently: P(A and B) = P(A) × P(B)

Step 2: Calculate unconditional probabilities

P(Math) = 130/200 = 0.65

P(English) = 70/200 = 0.35

P(Freshman) = 100/200 = 0.50

P(Sophomore) = 100/200 = 0.50

Step 3: Calculate conditional probabilities

P(Math | Freshman) = 60/100 = 0.60

P(Math | Sophomore) = 70/100 = 0.70

P(English | Freshman) = 40/100 = 0.40

P(English | Sophomore) = 30/100 = 0.30

Step 4: Test independence

If independent, P(Math | Freshman) should equal P(Math) = 0.65

Actual: P(Math | Freshman) = 0.60 ≠ 0.65

If independent, P(Math | Sophomore) should equal P(Math) = 0.65

Actual: P(Math | Sophomore) = 0.70 ≠ 0.65

Step 5: Verify with joint probability method

If independent: P(Freshman and Math) = P(Freshman) × P(Math)

Expected: 0.50 × 0.65 = 0.325

Actual: 60/200 = 0.30 ≠ 0.325

Step 6: Draw conclusion

Since conditional probabilities differ from unconditional probabilities, and joint probabilities don't match expected values under independence, the variables are associated.

Sophomores are more likely to prefer Math than Freshmen.

Variables are dependent; P(Math|Sophomore) = 0.70 ≠ P(Math) = 0.65
Final answer:

Grade level and favorite subject are not independent. There is an association: Sophomores are more likely to prefer Math (70%) than Freshmen (60%). The probability of preferring Math changes based on grade level, indicating dependence between the variables.

Applied rules:

• Independence test: P(A|B) = P(A) for all combinations

• Joint probability: P(A and B) = P(A) × P(B) under independence

• Association evidence: Differences in conditional probabilities

Two-Way Table Analysis Framework
P(A|B) = \frac{P(A \cap B)}{P(B)}
Conditional Probability Formula
Joint Freq.
Internal cells
P(A \cap B)
Intersection
Marginal Freq.
Row/Col totals
P(A) or P(B)
Individual probabilities
Conditional Freq.
P(A|B) = P(A \cap B)/P(B)
Within-group
Key definitions:

Contingency table: A two-way table showing the frequency distribution of two categorical variables.

Relative frequencies: Proportions calculated as frequency ÷ total observations.

Independence: Two variables are independent if the occurrence of one doesn't affect the probability of the other.

Analysis process:
  1. Construct table: Fill in joint frequencies
  2. Calculate marginals: Row and column totals
  3. Compute relative frequencies: Joint, marginal, and conditional
  4. Test independence: Compare conditional to marginal probabilities
  5. Interpret associations: Identify patterns in the data
Tip 1: Always verify that grand total equals sample size.
Tip 2: Conditional probabilities reveal associations between variables.
Tip 3: If variables are independent, conditional probabilities equal marginal probabilities.
Tip 4: Look for patterns in conditional probabilities to identify associations.
Table Properties: Sum of all joint frequencies equals grand total, marginal frequencies represent individual variable distributions.
Independence Properties: P(A|B) = P(A), P(B|A) = P(B), P(A ∩ B) = P(A) × P(B).
Association patterns:

• Positive association: Higher conditional probability than marginal probability

• Negative association: Lower conditional probability than marginal probability

• Independence: Conditional probability equals marginal probability

Solution: Exercises 4 to 5
4 Relative Frequency Conversion
Exercise 4
Convert the table from Exercise 1 to relative frequencies. Calculate joint, marginal, and conditional relative frequencies. What insights does this provide?
Definition:

Relative frequency: The proportion of observations in each category, calculated as frequency ÷ total observations.

Joint relative frequency: Proportion in a specific cell of the table.

Marginal relative frequency: Proportion for a row or column total.

Step 1: Recall the original frequency table
Favorite Subject Math English Total
Freshman 60 40 100
Sophomore 70 30 100
Total 130 70 200
Step 2: Calculate joint relative frequencies (divide each cell by 200)
Favorite Subject Math English Total
Freshman 0.30 0.20 0.50
Sophomore 0.35 0.15 0.50
Total 0.65 0.35 1.00
Step 3: Calculate conditional relative frequencies

Given Grade Level (row conditional):

P(Math | Freshman) = 60/100 = 0.60

P(English | Freshman) = 40/100 = 0.40

P(Math | Sophomore) = 70/100 = 0.70

P(English | Sophomore) = 30/100 = 0.30

Step 4: Calculate conditional relative frequencies (given Subject)

Given Subject (column conditional):

P(Freshman | Math) = 60/130 = 0.462

P(Sophomore | Math) = 70/130 = 0.538

P(Freshman | English) = 40/70 = 0.571

P(Sophomore | English) = 30/70 = 0.429

Step 5: Analyze the insights

Joint relative frequencies show the overall distribution of combinations

Row conditional frequencies reveal grade-level preferences

Column conditional frequencies reveal subject-level grade composition

Joint rel freq: (0.30, 0.20, 0.35, 0.15); Conditionals show grade-subject association
Final answer:

The relative frequency table shows that 35% of students are Sophomores who prefer Math, which is the largest single group. Conditional analysis reveals that Sophomores are more likely to prefer Math (70%) than Freshmen (60%), indicating an association between grade level and subject preference.

Applied rules:

• Joint relative frequency: Cell value ÷ Grand total

• Conditional frequency: Cell value ÷ Relevant marginal total

• Sum property: Marginal relative frequencies sum to 1

5 Real-World Application
Exercise 5
A study surveyed 500 people about their preferred news source (TV, Online, Print) and age group (Young Adult, Middle Age, Senior). The results show: Young Adults: TV=40, Online=110, Print=10; Middle Age: TV=60, Online=90, Print=40; Seniors: TV=80, Online=30, Print=40. Analyze the association between age and news preference.
Definition:

Contingency analysis: Examining the relationship between two categorical variables.

Segmentation: Dividing populations into meaningful groups for analysis.

Step 1: Create the contingency table
News Source TV Online Print Total
Young Adult 40 110 10 160
Middle Age 60 90 40 190
Senior 80 30 40 150
Total 180 230 90 500
Step 2: Calculate conditional probabilities by age group

Young Adults:

P(TV | YA) = 40/160 = 0.25, P(Online | YA) = 110/160 = 0.688, P(Print | YA) = 10/160 = 0.063

Middle Age:

P(TV | MA) = 60/190 = 0.316, P(Online | MA) = 90/190 = 0.474, P(Print | MA) = 40/190 = 0.211

Seniors:

P(TV | S) = 80/150 = 0.533, P(Online | S) = 30/150 = 0.200, P(Print | S) = 40/150 = 0.267

Step 3: Calculate overall probabilities

P(TV) = 180/500 = 0.36, P(Online) = 230/500 = 0.46, P(Print) = 90/500 = 0.18

Step 4: Compare conditional to overall probabilities

Young Adults strongly prefer online (68.8% vs 46% overall)

Seniors strongly prefer TV (53.3% vs 36% overall)

Middle Age shows more balanced preferences

Step 5: Draw conclusions about association

There is a clear association between age and news preference

Young adults favor online sources

Seniors favor traditional sources (TV and print)

Middle age group is more diverse in preferences

Strong association: Young → Online, Seniors → Traditional sources
Final answer:

There is a strong association between age and news source preference. Young adults overwhelmingly prefer online sources (68.8%), while seniors prefer traditional sources (TV: 53.3%, Print: 26.7%). Middle age adults show more balanced preferences. This demonstrates how demographic factors influence media consumption habits.

Applied rules:

• Association detection: Compare conditional to marginal probabilities

• Pattern identification: Look for significant differences in conditional distributions

• Real-world interpretation: Connect statistical findings to practical implications

Comprehensive Guide to Two-Way Tables
\text{Conditional Relative Frequency} = \frac{\text{Joint Frequency}}{\text{Marginal Frequency}}
Conditional Frequency Formula
Key definitions:

Two-way table: A contingency table displaying the frequency distribution of two categorical variables.

Joint frequency: The count of observations that fall into a specific combination of categories.

Marginal frequency: The total count for each category of a variable, found in row or column totals.

Conditional frequency: The frequency of one variable given a specific value of the other variable.

Independence: Two variables are independent if the occurrence of one doesn't affect the probability of the other.

Analysis process:
  1. Table construction: Organize data into rows and columns
  2. Frequency calculation: Fill in joint, marginal, and conditional frequencies
  3. Association testing: Compare conditional to marginal probabilities
  4. Pattern interpretation: Identify meaningful relationships
  5. Conclusion drawing: State findings in context
Tip 1: Always check that row and column totals match the grand total.
Tip 2: Conditional frequencies reveal the strength and direction of associations.
Tip 3: Convert to percentages for easier interpretation of relative frequencies.
Tip 4: Look for patterns across conditional distributions to identify associations.
Tip 5: Independence means conditional probabilities equal marginal probabilities.
Tip 6: Use row percentages when comparing across categories of the row variable.
Table Properties: Sum of all joint frequencies equals grand total, marginal frequencies represent individual variable distributions, conditional frequencies sum to 1 within each row/column.
Independence Tests: P(A|B) = P(A), P(B|A) = P(B), P(A ∩ B) = P(A) × P(B), no association between variables.
Association Patterns: Positive association (higher conditional than marginal), negative association (lower conditional than marginal), or independence.
Key relationships:

• Joint = Marginal × Conditional: P(A ∩ B) = P(A) × P(B|A)

• Independence: P(A|B) = P(A), P(B|A) = P(B)

• Association: Conditional probabilities differ from marginal probabilities

• Sum property: Conditional probabilities in each row/column sum to 1

Contingency Table Visualization
Understanding Contingency Tables
Key characteristics of contingency table analysis:
Joint frequencies: Count of observations in specific cells
Marginal frequencies: Totals for rows and columns
Conditional frequencies: Probabilities within specific groups
Independence: No association between variables
Association: Relationship between categorical variables

Analysis: Contingency tables reveal relationships between categorical variables through frequency patterns.

  • Joint frequencies: Show specific category combinations
  • Marginal frequencies: Show individual variable distributions
  • Conditional frequencies: Reveal associations between variables
  • Independence testing: Compare conditional to marginal probabilities
  • Pattern identification: Look for meaningful relationships

Questions & Answers

Question: How do I know which variable should be the row variable and which should be the column variable in a two-way table?

Answer: The choice depends on your research question:

  • Explanatory variable: Usually placed in rows (the variable you think influences the other)
  • Response variable: Usually placed in columns (the variable you're measuring)
  • Research question: If asking "how does X affect Y?", X is explanatory, Y is response

Examples:

  • "Does gender affect study time?" → Gender (rows), Study time (columns)
  • "What's the relationship between education and income?" → Education (rows), Income (columns)

The table structure doesn't affect the mathematical relationships, but it affects interpretation and which conditional probabilities are most natural to calculate.

Question: What's the difference between row percentages and column percentages in a two-way table?

Answer: They represent different conditional probabilities:

  • Row percentages: Conditional probabilities given the row variable (P(Column|Row))
  • Column percentages: Conditional probabilities given the column variable (P(Row|Column))

Example: In a table of Grade Level vs Subject Preference:

  • Row percentage: "Of all Freshmen, what % prefer Math?"
  • Column percentage: "Of all Math lovers, what % are Freshmen?"

Choose based on your research question: use row percentages when comparing across categories of the row variable, column percentages when comparing across categories of the column variable.

Question: How do I determine if the association between two variables is strong or weak?

Answer: Assess association strength by examining conditional probabilities:

  • Strong association: Large differences between conditional and marginal probabilities
  • Moderate association: Moderate differences between conditional and marginal probabilities
  • Weak association: Small differences between conditional and marginal probabilities

Measurement approaches:

  • Compare conditional probabilities to marginal probabilities
  • Look for patterns in conditional probability distributions
  • Calculate standardized residuals (advanced method)

A rule of thumb: if conditional probabilities differ by more than 10-15 percentage points from marginal probabilities, there's likely a meaningful association.

Question: Can I use two-way tables with quantitative variables, or only categorical variables?

Answer: Two-way tables are designed for categorical variables, but quantitative variables can be converted:

  • Grouping: Convert quantitative variables into categories (e.g., age groups: 18-25, 26-35, etc.)
  • Binary classification: Create categories like "above/below median" or "high/medium/low"
  • Intervals: Define meaningful intervals for the quantitative variable

Example: Instead of using exact test scores (quantitative), you could categorize them as "Below 70", "70-85", "Above 85" to create a two-way table with another categorical variable.

For true quantitative variables, other methods like correlation or regression are more appropriate than two-way tables.