Phi coefficient for two binary variables
The phi coefficient measures association between two binary categorical variables in a 2 × 2 table. With cells arranged as a, b in the first row and c, d in the second, φ = (ad − bc)/√[(a+b)(c+d)(a+c)(b+d)].
The numerator compares the diagonal products. Its sign depends on which categories are called the first row and first column: reversing one binary coding reverses the sign, while reversing both leaves the sign unchanged.
Provided all row and column margins are nonzero, φ lies from −1 to +1, and its magnitude |φ| lies from 0 to 1 and reflects association strength for the chosen binary coding.
As an illustrative calculation, a table with cells 18, 12, 7, and 23 has numerator 18×23 − 12×7 = 330. Its denominator is √(30×30×25×35), so the result can be computed from the table margins. Do not reuse those values for a separate data set.
Phi describes association in the observed binary table. It does not by itself establish a causal mechanism, control confounding, or replace a substantive review of how the categories and sample were obtained.
A 2×2 table has a = 20, b = 5, c = 10, and d = 15. What is φ to three significant figures?
A 2×2 table has nonzero row and column margins and a nonzero phi coefficient. A researcher reverses the coding of the row variable while leaving the column coding unchanged. What happens to phi?