Pada Tingkat Apa tes


15

LATAR BELAKANG: Lewati dengan aman - ada di sini untuk referensi, dan untuk melegitimasi pertanyaan.

Pembukaan makalah ini berbunyi:

"Uji kontingensi chi-square Karl Pearson yang terkenal berasal dari statistik lain, yang disebut statistik z, berdasarkan pada distribusi Normal. Versi paling sederhana dari χ2 dapat ditunjukkan identik secara matematis dengan uji z yang setara. Tes ini menghasilkan hasil yang sama dalam semua keadaan. Untuk semua maksud dan tujuan "chi-squared" dapat disebut "z-squared". Nilai kritis χ2 untuk satu derajat kebebasan adalah kuadrat dari nilai kritis z yang sesuai. "

Ini telah dinyatakan beberapa kali dalam CV (di sini , di sini , di sini dan yang lainnya).

Dan memang kita bisa membuktikan bahwa χ1df2 setara denganX2denganXN(0,1):

Mari mengatakan bahwa XN(0,1) dan Y=X2 dan menemukan kepadatan Y dengan menggunakan cdf metode:

. Masalahnya adalah kita tidak dapat berintegrasi dalam kepadatan dekat dari distribusi normal. Tetapi kita dapat mengungkapkannya:p(Yy)=p(X2y)=p(yxy)

Mengambil turunan:

FX(y)=FX(y)FX(y).

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

Karena nilai-nilai normal simetris:pdf

. Menyamakan ini kepdfnormal (sekarangxdalampdfakanfX(y)=FX(y)1ypdfxpdf untuk dicolokkan kee - x 2yex22 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=i=1n(OiEi)2Ei=Ni=1npi(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?


But these are two identical tests. Z squared is the chi-square statistic. Let you have 2x2 frequency table where columns are the two groups and the rows are "success" and "failure". Then the so called expected frequencies of the chi-square test in a given column is the weighted (by the groups' N) average column (group) profile multiplied by that group's N. Thus, it comes 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, the z-test of proportions.
ttnphns

In the example on the last hyperlink the χ2 is almost the square of the z-test statistic, but not quite, and the p-values are different. Also, when you look at the formulas for the rest statistics above, is it truly immediate that they are identical? Or even one the square of the other?
Antoni Parellada

2
In chisq.test(), have you tried using correct=FALSE?
mark999

1
Indeed, Antoni. Both tests exist with or without the Yates. Could it be that you compute one with but the other without it?
ttnphns

1
Thank you! You were (predictably) correct. With the Yates correction off, one is just the square of the other. I edited the question accordingly, although a bit fast. I still would like to prove algebraically that both test statistics are the same (or one the square of the other), and understand why the p-values are different.
Antoni Parellada

Jawaban:


12

Let us have a 2x2 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(n12n2+n1n22)pqN2

Divide both numerator and denominator by the (n12n2+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.


@ttnphs This is great! Any chance you could clarify the intermediate step in the first equation (χ2) formula - I don't see how the q's go away after the equal sign.
Antoni Parellada

@ttnphs When I expand it I get n1[(p1p)2p+(q1q)2q]+n2[(p2p)2p+(q2q)2q]=n1(q(p2+p(2p12q1+p12)+p(q2+q12)pq)+n2(q(p2+p(2p22q2)+p22)+p(q2+q22)pq)
Antoni Parellada

@ttnphs ... Or some reference so it's less work to type the latex... And I'll promptly and happily 'accept' the answer...
Antoni Parellada

@Antoni, expansion inserted.
ttnphns

@ttnphns Awesome!
Antoni Parellada
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.