Cross Validated is a question and answer site for people interested in statistics, machine learning, data analysis, data mining, and data visualization. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Going through the Wiki article on the Phi coefficient, I've noticed that for paired binary data "a Pearson correlation coefficient estimated for two binary variables will return the phi coefficient".

Upon running a quick simulation I found this to not be the case. However, it appears that the phi coefficient does approximate the pearson's correlation coefficient.

x <- c(1,   1,  0,  0,  1,  0,  1,  1,  1)
y <- c(1,   1,  0,  0,  0,  0,  1,  1,  1)
sqrt(chisq.test(table(x,y))$statistic/length(x)) # phi

x <- rep(x, 1000)
y <- rep(y, 1000)
sqrt(chisq.test(table(x,y))$statistic/length(x)) # phi
# it now DOES approximates the pearsons correlation.

But it is not apparent to me why (mathematically) this is the case.

share|improve this question
up vote 3 down vote accepted

By default, chisq.test() applies a continuity correction when computing the test statistic for 2x2 tables. If you switch off this behavior, then:

x = c(1,  1,  0,  0,  1,  0,  1,  1,  1)
y = c(1,  1,  0,  0,  0,  0,  1,  1,  1)
sqrt(chisq.test(table(x,y), correct=FALSE)$statistic/length(x)) # phi

will give you exactly the same answer. And this essentially also answers why $\sqrt{\chi^2/n}$ with the continuity correction approximates cor(x,y) -- as $n$ increases, the continuity correction has less and less influence on the result.

The continuity correction is described here: Yates's correction for continuity

share|improve this answer
Thanks Wolfgang, good catch! – Tal Galili Jan 17 '13 at 22:24
I am also interested as to why the two would give the exact same value. Should I ask this on a different question? – Tal Galili Jan 17 '13 at 22:25
@Tal, for binary data, that is, for 2x2 contingency table, phi degenerates into abs(r). This can be shown by the fact that their classic formulas can be reduced to the common one shown here – ttnphns Jan 18 '13 at 8:54
Does anyone have a textbook or journal reference for this? I'd love to be able to give to my clients so they could cite it... – emudrak Aug 1 '14 at 17:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.