Phi Coefficient — Definition, Formula & Example
The phi coefficient is a number between -1 and 1 that measures how strongly two yes/no variables are associated. For example, it can tell you whether students who do the homework also tend to pass the quiz.
For two dichotomous variables summarized in a 2×2 contingency table with cell counts , the phi coefficient is the Pearson correlation coefficient computed after coding each variable as 0 or 1. It equals the formula below. It is undefined when any row or column total is 0. In machine learning, the same quantity is called the Matthews correlation coefficient.
Key Formula
Where:
- = Count of cases that are "yes" on both variables
- = Count of cases that are "yes" on the row variable and "no" on the column variable
- = Count of cases that are "no" on the row variable and "yes" on the column variable
- = Count of cases that are "no" on both variables
- = The phi coefficient, with
Worked Example
Problem: A teacher records 100 students. Of them, 40 did the homework and passed the quiz, and 10 did the homework but failed. Another 10 skipped the homework but passed, and 40 skipped the homework and failed. Find the phi coefficient.
Step 1: Put the counts into a 2×2 table with rows for homework (did, skipped) and columns for quiz (passed, failed). That gives , , , . Compute the numerator.
Step 2: Find the row totals and . Find the column totals and . Multiply them and take the square root.
Step 3: Divide the numerator by the denominator.
Answer: The phi coefficient is . This shows a fairly strong positive association: students who did the homework were much more likely to pass.
Why It Matters
In AP Statistics you analyze two-way tables. Phi turns a two-way table into a single correlation-style number, and for a 2×2 table it links to the chi-square statistic through , where is the uncorrected Pearson chi-square statistic. Data scientists use the same formula, under the name Matthews correlation coefficient, to grade spam filters and medical tests that sort cases into yes or no.
Common Mistakes
Mistake: Arranging the table in a different order and getting the opposite sign without noticing.
Correction: Swapping the two rows, or the two columns, flips the sign of but keeps its size. Put "yes/yes" in cell every time, so a positive means the two "yes" outcomes tend to occur together.
