At What Level is a χ2\chi^2 test Mathematically Identical to a zz-test of Proportions?

BACKGROUND: Skip safely – it’s here for reference, and to legitimize the question.

The opening of this paper reads:

“Karl Pearson’s famous chi-square contingency test is derived from another statistic, called the z statistic, based on the Normal distribution. The simplest versions of χ2 can be shown to be mathematically identical to equivalent z tests. The tests produce the same result in all circumstances. For all intents and purposes “chi-squared” could be called “z-squared”. The critical values of χ2 for one degree of freedom are the square of the corresponding critical values of z.”

This has been asserted multiple times in CV (here, here, here and others).

And indeed we can prove that χ21df is equivalent to X2 with XN(0,1):

Let’s say that XN(0,1) and that Y=X2 and find the density of Y by using the cdf method:

p(Yy)=p(X2y)=p(yxy). The problem is that we cannot integrate in close form the density of the normal distribution. But we can express it:

FX(y)=FX(y)FX(y). Taking the derivative:

fX(y)=FX(y)12y+FX(y)12y.

Since the values of the normal pdf are symmetrical:

fX(y)=FX(y)1y. Equating this to the pdf of the normal (now the x in the pdf will be y to be plugged into the ex22 part of the normal pdf); and remembering to in include 1y at the end:

fX(y)=FX(y)1y=12πey21y=12πey2y121

Compare to the pdf of the chi square:

fX(x)=12ν/2Γ(ν2)ex2xν21

Since Γ(1/2)=π, for 1 df, we have derived exactly the pdf of the chi square.

Further, if we call the function prop.test() in R we are invoking the same χ2 test as if we decide upon chisq.test().

THE QUESTION:

So I get all these points, yet I still don’t know how they apply to the actual implementation of these two tests for two reasons:

  1. A z-test is not squared.

  2. The actual test statistics are completely different:

The value of the test-statistic for a χ2 is:

χ2=ni=1(OiEi)2Ei=Nni=1pi(Oi/Npipi)2
where

χ2 = Pearson’s cumulative test statistic, which asymptotically approaches a χ2 distribution. Oi = the number of observations of type i; N = total number of observations; Ei = Npi = the expected (theoretical) frequency of type i, asserted by the null hypothesis that the fraction of type i in the population is pi;
n = the number of cells in the table.

On the other hand, the test statistic for a z-test is:

Z=x1n1x2n2p(1p)(1/n1+1/n2) with p=x1+x2n1+n2, where x1 and x2 are the number of “successes”, over the number of subjects in each one of the levels of the categorical variables, i.e. n1 and n2.

This formula seems to rely on the binomial distribution.

These two tests statistics are clearly different, and result in different results for the actual test statistics, as well as for the p-values: 5.8481 for the χ2 and 2.4183 for the z-test, where 2.41832=5.84817 (thank you, @mark999). The p-value for the χ2 test is 0.01559, while for the z-test is 0.0077. The difference explained by two-tailed versus one-tailed: 0.01559/2=0.007795 (thank you @amoeba).

So at what level do we say that they are one and the same?

Answer

Let us have a 2×2 frequency table where columns are two groups of respondents and rows are the two responses “Yes” and “No”. And we’ve turned the frequencies into the proportions within group, i.e. into the vertical profiles:

      Gr1   Gr2  Total
Yes   p1    p2     p
No    q1    q2     q
      --------------
     100%  100%   100%
      n1    n2     N

The usual (not Yates corrected) χ2 of this table, after you substitute proportions instead of frequencies in its formula, looks like this:

n1[(p1p)2p+(q1q)2q]+n2[(p2p)2p+(q2q)2q]=n1(p1p)2+n2(p2p)2pq.

Remember that p=n1p1+n2p2n1+n2, the element of the weighted average profile of the two profiles (p1,q1) and (p2,q2), and plug it in the formula, to obtain

...=(p1p2)2(n21n2+n1n22)pqN2

Divide both numerator and denominator by the (n21n2+n1n22) and get (p1p2)2pq(1/n1+1/n2)=Z2,

the squared z-statistic of the z-test of proportions for “Yes” response.

Thus, the 2x2 homogeneity Chi-square statistic (and test) is equivalent to the z-test of two proportions. The so called expected frequencies computed in the chi-square test in a given column is the weighted (by the group n) average vertical profile (i.e. the profile of the “average group”) multiplied by that group’s n. Thus, it comes out that chi-square tests the deviation of each of the two groups profiles from this average group profile, – which is equivalent to testing the groups’ profiles difference from each other, which is the z-test of proportions.

This is one demonstration of a link between a variables association measure (chi-square) and a group difference measure (z-test statistic). Attribute associations and group differences are (often) the two facets of the same thing.


(Showing the expansion in the first line above, By @Antoni’s request):

n1[(p1p)2p+(q1q)2q]+n2[(p2p)2p+(q2q)2q]=n1(p1p)2qpq+n1(q1q)2ppq+n2(p2p)2qpq+n2(q2q)2ppq=n1(p1p)2(1p)+n1(1p11+p)2p+n2(p2p)2(1p)+n2(1p21+p)2ppq=n1(p1p)2(1p)+n1(pp1)2p+n2(p2p)2(1p)+n2(pp2)2ppq=[n1(p1p)2][(1p)+p]+[n2(p2p)2][(1p)+p]pq=n1(p1p)2+n2(p2p)2pq.

Attribution
Source : Link , Question Author : Antoni Parellada , Answer Author : ttnphns

Leave a Comment