Tutorials › Introduction to Statistics › Conditional Probabilities from Two-Way Tables

Conditional Probability and Bayes’ Rule · Tutorial 327 of 996

Conditional Probabilities from Two-Way Tables

Use a two-way table to restrict attention to the group named after “given,” then divide the relevant cell count by that group’s total.

Beginner 9 min read

What You'll Learn

  • Identify a joint count and a marginal total in a two-way table
  • Choose the correct row or column total for a conditional probability
  • Calculate conditional probabilities from counts and report them as proportions or percentages
  • Distinguish probabilities that condition on different groups in the same table
  • Check that a conditioning group has a positive count before calculating

Why the Denominator Changes

A two-way table organizes counts according to two categorical variables. It can answer questions such as “Among students in their first year, what proportion ride the bus?” or “Among bus riders, what proportion are first-year students?” These questions involve the same people and the same cell of the table, but they have different answers because they refer to different groups. The key is to use the total count for the group named after given as the denominator.

A conditional probability focuses on outcomes that satisfy a condition. In a two-way table, the condition selects a row or a column; the numerator is the count in the cell that also satisfies the event of interest. If the condition selects a row, use that row’s total. If it selects a column, use that column’s total.

Definition: For events \(A\) and \(B\), with \(P(B)>0\), the conditional probability of \(A\) given \(B\) is \(P(A\mid B)=P(A\cap B)/P(B)\). In a two-way table of counts, if each of the counted individuals is treated as equally likely to be selected, this is the count satisfying both \(A\) and \(B\), divided by the count satisfying \(B\). The count satisfying \(B\) must be positive.

The notation \(P(A\mid B)\) is read “the probability of \(A\) given \(B\).” The event after the vertical bar, \(B\), specifies the restricted group. It determines the denominator. The event before the bar, \(A\), specifies what we count within that group. When both events hold, the table entry is in their shared cell.

Finding the Relevant Counts

Consider this hypothetical table of 200 students, classified by year at college and usual way of commuting. Each student is counted once, in one row and one column. The totals at the ends of rows and bottoms of columns are called marginal totals: each sums the counts across the other variable.

YearBusCarWalkTotal
First year42183090
Second year283250110
Total705080200

The entry 42 counts students who are both first-year students and bus riders. It is a joint count: both descriptions apply. The number 90 is the total number of first-year students, while 70 is the total number of bus riders. These totals answer different “given” questions, so they cannot be substituted for one another indiscriminately.

Worked Example: Bus Riding Among First-Year Students

Using the table, find the probability that a student rides the bus given that the student is in the first year. Treat selection as equally likely among the 200 students.

Let \(A\) be the event that the student rides the bus, and let \(B\) be the event that the student is in the first year. The phrase “given that the student is in the first year” restricts attention to the first-year row. That row contains 90 students, and 42 of them ride the bus.

$$ P(A\mid B)=\frac{\text{first-year students who ride the bus}}{\text{first-year students}} =\frac{42}{90}=0.4667 $$

Thus, the conditional probability is about 0.467, or 46.7%. In this table, about 46.7% of first-year students ride the bus. The denominator is 90, not the overall total of 200, because the condition restricts the group to first-year students.

A useful way to select the denominator is to read the conditional notation from right to left: first identify the event after the bar, then find its total in the table. Only after the restricted group is clear should you locate the cell that also meets the event before the bar.

1
Read the condition.
In \(P(A\mid B)\), identify \(B\), the event after the bar. It defines the group being considered.
2
Find its total.
Locate the row or column corresponding to \(B\). Its marginal total is the denominator.
3
Find the shared cell.
Locate the count that satisfies both \(A\) and \(B\). This joint count is the numerator.
4
Divide and interpret.
Divide the joint count by the conditioning-group total, then describe the result as a proportion within that group.

Conditioning on a Column

The condition does not always select a row. If the group named after “given” corresponds to a column, the column total is the denominator. The same table can therefore support conditional probabilities with different denominators.

Worked Example: First-Year Status Among Bus Riders

Find the probability that a student is in the first year given that the student rides the bus.

Let \(A\) be the event that the student is in the first year, and \(B\) the event that the student rides the bus. The condition is now bus riding, so restrict attention to the bus column. There are 70 bus riders, of whom 42 are first-year students.

$$ P(A\mid B)=\frac{\text{bus riders who are first-year students}}{\text{bus riders}} =\frac{42}{70}=0.6000 $$

Among the students in this table who ride the bus, 60.0% are first-year students. This is not the same quantity as the probability in the previous example: there, the group was first-year students; here, it is bus riders. The numerator is 42 in both calculations, but the denominators differ because the conditions differ.

Key takeaway: The cell shared by the event and condition supplies the numerator. The marginal total for the condition—not necessarily the grand total—supplies the denominator.

A Short Justification

The count formula follows directly from restricting the group under consideration. Suppose a table represents \(N\) equally likely individuals. Event \(B\) contains \(n_B\) individuals, and \(A\cap B\) contains \(n_{A\cap B}\). Once attention is limited to \(B\), there are \(n_B\) possible individuals left in the restricted group. Of these, \(n_{A\cap B}\) also satisfy \(A\). Therefore, the fraction of the restricted group that satisfies \(A\) is:

$$ \frac{n_{A\cap B}}{n_B} $$

In the original group of \(N\), the corresponding probabilities are \(P(A\cap B)=n_{A\cap B}/N\) and \(P(B)=n_B/N\). Since \(n_B>0\), dividing these probabilities gives:

$$ \frac{P(A\cap B)}{P(B)} =\frac{n_{A\cap B}/N}{n_B/N} =\frac{n_{A\cap B}}{n_B} $$

The grand total cancels. This explains both the conditional probability formula and why the denominator in a table is the total for the conditioning group. If the condition has count zero, then \(P(B)=0\), and the conditional probability is not defined by this formula.

Reading Carefully When Both Variables Are Named

In ordinary language, two questions can mention the same categories but condition in opposite directions. “Among people who received a reminder, what proportion attended?” asks for attendance given a reminder. “Among people who attended, what proportion received a reminder?” asks for a reminder given attendance. The relevant column or row total changes along with the condition.

Worked Example: Attendance and Appointment Reminders

Suppose a hypothetical table records 300 appointments, classified by whether a reminder was sent and whether the patient attended.

Reminder sent?AttendedDid not attendTotal
Yes10812120
No12654180
Total23466300

First find the proportion attending among appointments with a reminder. The condition selects the “Yes” row, with 120 appointments; 108 of these were attended.

$$ P(\text{attended}\mid\text{reminder sent}) =\frac{108}{120}=0.9000 $$

So 90.0% of the appointments in the reminder group were attended. Now reverse the condition: find the proportion receiving a reminder among appointments that were attended. The condition selects the “Attended” column, with 234 appointments; 108 of these had a reminder.

$$ P(\text{reminder sent}\mid\text{attended}) =\frac{108}{234}=0.4615 $$

Thus, 46.2% of the attended appointments had a reminder. These values differ because they describe proportions within different groups. The table shows a comparison of recorded categories; by itself, it does not establish that reminders caused attendance.

Common Mistakes and Checks

The most frequent error is dividing by the grand total even though the question asks for a conditional probability. The grand total is appropriate for a proportion of the entire table, but conditioning narrows the relevant group. Another common error is choosing the correct number from the table but using the wrong marginal total.

  • Wrong reasoning: “There are 42 first-year bus riders out of 200 students, so the probability a student rides the bus given that the student is in the first year is \(42/200\).”
  • Correction: The condition says the student is in the first year. Use the 90 first-year students as the denominator: \(42/90\). The fraction \(42/200\) instead describes the proportion of all students who are both first-year and bus riders.
  • Wrong reasoning: “The numerator is 42 in either question, so \(P(\text{bus}\mid\text{first year})\) and \(P(\text{first year}\mid\text{bus})\) must be equal.”
  • Correction: The conditions are different, so the denominators are different: \(42/90\) versus \(42/70\). Always identify the group after “given” before dividing.
  • Wrong reasoning: “A conditional probability can be calculated even if the condition’s row or column total is zero.”
  • Correction: If the condition has no individuals, its total is zero and the required division is undefined.

Before finalizing a calculation, check that the numerator is a part of the denominator’s group, that the denominator matches the condition, and that the answer lies between 0 and 1. State the group in words so the interpretation is clear. For example, “46.7% of first-year students ride the bus” identifies the condition and the event; “46.7% ride the bus” does not.

Check Your Understanding

For each question, identify the conditioning group before choosing a denominator.

  1. In the student table, what is the probability that a student walks given that the student is in the second year? State the numerator, denominator, and interpretation.
  2. In the student table, what is the probability that a bus rider is in the second year? Which marginal total is the denominator?
  3. In the appointment table, calculate the probability of not attending given that no reminder was sent. Interpret the result in context.
  4. Explain why the count for both events belongs in the numerator of a conditional probability from a two-way table.
  5. What does a zero total for the conditioning row or column imply about the conditional probability from that table?