The formula
A 2×2 table has four cells, a, b, c and d, arranged like this:
| Y: yes | Y: no | Total | |
|---|---|---|---|
| X: yes | a | b | a + b |
| X: no | c | d | c + d |
| Total | a + c | b + d | n |
φ = (ad − bc) / √((a + b)(c + d)(a + c)(b + d))
The numerator sets the products of the two diagonals against each other. Under the root are the four totals: two row totals and two column totals.
100 students are asked whether they exercise and whether they sleep well:
| Sleep well | Sleep badly | Total | |
|---|---|---|---|
| Exercise | 30 | 10 | 40 |
| Don’t exercise | 15 | 45 | 60 |
| Total | 45 | 55 | 100 |
φ = (30 · 45 − 10 · 15) / √(40 · 60 · 45 · 55) = 1,200 / √5,940,000 ≈ 1,200 / 2,437 ≈ 0.49.
A moderate positive association: in this group, the students who exercise sleep well more often. Whether the exercise is the cause, the number does not say.
The cells have to be in place
The formula takes a and d to be the diagonal where the two variables agree. Swap the order and you get a different number:
| Numerator | φ | |
|---|---|---|
| Wrong: ab − cd | 30 · 10 − 15 · 45 = −375 | ≈ −0.15 |
| Right: ad − bc | 30 · 45 − 10 · 15 = 1,200 | ≈ 0.49 |
Check the denominator too: each cell should appear in exactly two of the four totals.
The sign depends on how the table is laid out
Swap the rows, so that “don’t exercise” is on top: now a = 15, b = 45, c = 30, d = 10, and φ = (15 · 10 − 45 · 30) / 2,437 ≈ −0.49. The same association with the sign reversed. The sign says only which way the association runs in the order you chose; the size is the same.
With no association at all the numerator is zero. With 20 and 20 in the first row and 30 and 30 in the second, ad − bc = 600 − 600 = 0, and φ = 0: half of each group sleeps well.
How it relates to other measures
| Measure | Relation to φ |
|---|---|
| Correlation coefficient r | φ is r computed on two variables coded 0 and 1 |
| Chi-square statistic χ² | φ² = χ² / n for a 2×2 table |
The link to the chi-square statistic is what decides whether the association is statistically significant: φ measures how strong it is, the χ² test whether it could be chance. For two variables with many values, use the correlation coefficient.
Common mistakes
- Cells in the wrong order. ab − cd instead of ad − bc gives a different number altogether.
- Proportions instead of counts. The formula works on counts; with row percentages the totals no longer match.
- Reading the sign without the table. A negative φ only means something together with the order of the rows and columns.
- Association read as cause. φ says two things occur together, not why.
Questions people ask
What counts as a strong association?
It depends on the field, but the benchmarks used for the correlation coefficient are common: around 0.1
weak, around 0.3 moderate and from 0.5 strong. When the row and column totals differ φ cannot reach ±1,
so a value of 0.5 may be close to the largest possible.
What if a row or column is empty?
Then one of the totals is 0, the denominator is 0 and φ is undefined. A variable that only takes one value
cannot vary with anything.
Is phi the same as Cramér’s V?
For a 2×2 table, yes, apart from the sign: Cramér’s V is |φ|. Cramér’s V exists to measure association in
larger tables, where phi is not defined in the same way.
Is it the same as the Matthews correlation coefficient?
Yes. In machine learning the same formula, applied to a confusion matrix of true and false positives and
negatives, goes by the name Matthews correlation coefficient.