Mathwords logoMathwords

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 a,b,c,da, b, c, d, the phi coefficient φ\varphi 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

φ=ad−bc(a+b)(c+d)(a+c)(b+d)\varphi = \frac{ad - bc}{\sqrt{(a+b)(c+d)(a+c)(b+d)}}
Where:
  • aa = Count of cases that are "yes" on both variables
  • bb = Count of cases that are "yes" on the row variable and "no" on the column variable
  • cc = Count of cases that are "no" on the row variable and "yes" on the column variable
  • dd = Count of cases that are "no" on both variables
  • φ\varphi = The phi coefficient, with −1≤φ≤1-1 \le \varphi \le 1

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 a=40a = 40, b=10b = 10, c=10c = 10, d=40d = 40. Compute the numerator.
ad−bc=(40)(40)−(10)(10)=1600−100=1500ad - bc = (40)(40) - (10)(10) = 1600 - 100 = 1500
Step 2: Find the row totals a+b=50a+b = 50 and c+d=50c+d = 50. Find the column totals a+c=50a+c = 50 and b+d=50b+d = 50. Multiply them and take the square root.
(50)(50)(50)(50)=6,250,000=2500\sqrt{(50)(50)(50)(50)} = \sqrt{6{,}250{,}000} = 2500
Step 3: Divide the numerator by the denominator.
φ=15002500=0.6\varphi = \frac{1500}{2500} = 0.6
Answer: The phi coefficient is φ=0.6\varphi = 0.6. 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 φ2=χ2/n\varphi^2 = \chi^2 / n, where χ2\chi^2 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 φ\varphi but keeps its size. Put "yes/yes" in cell aa every time, so a positive φ\varphi means the two "yes" outcomes tend to occur together.

Related Terms