Auf welcher Ebene ist ein


15

HINTERGRUND: Sicher überspringen - dient als Referenz und zur Rechtfertigung der Frage.

Die Eröffnung dieses Papiers lautet:

"Karl Pearsons berühmter Chi-Quadrat-Kontingenztest leitet sich aus einer anderen Statistik ab, die als z-Statistik bezeichnet wird und auf der Normalverteilung basiert. Die einfachsten Versionen von χ2 können mathematisch mit äquivalenten z-Tests identisch sein. Die Tests liefern dasselbe Ergebnis unter allen Umständen. In jeder Hinsicht könnte "Chi-Quadrat" als "Z-Quadrat" bezeichnet werden. Die kritischen Werte von χ2 für einen Freiheitsgrad sind das Quadrat der entsprechenden kritischen Werte von z. "

Dies wurde mehrfach im Lebenslauf behauptet ( hier , hier , hier und andere).

Und tatsächlich können wir beweisen, dass ist äquivalent zuX2mitXN(0,1):χ1df2X2XN(0,1)

Nehmen wir an, dass und Y = X 2 und ermitteln Sie die Dichte von Y mit der c d f -Methode:XN(0,1)Y=X2Ycdf

. Das Problem ist, dass wir die Dichte der Normalverteilung nicht in enger Form integrieren können. Aber wir können es ausdrücken:p(Yy)=p(X2y)=p(yxy)

Ableitung nehmen:

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

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

Da die Werte der Normalen symmetrisch sind:pdf

. Gleichzusetzen mit dempdffX(y)=FX(y)1ypdf der normalen (jetzt in dem p d f wird xpdfy an das ex22 Teil der Normalen ); und daran erinnern, in 1 enthaltenpdf am Ende:1y

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

Vergleichen Sie mit dem PDF des Chi-Quadrats:

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

Da , für1df haben wir genau daspdfdes Chi-Quadrats abgeleitet.Γ(1/2)=π1pdf

Wenn wir die Funktion prop.test()in R aufrufen , rufen wir den gleichen -Test auf, als ob wir uns entscheiden würden .χ2chisq.test()

DIE FRAGE:

Ich verstehe also alle diese Punkte, weiß aber aus zwei Gründen noch nicht, wie sie auf die tatsächliche Implementierung dieser beiden Tests angewendet werden:

  1. Ein Z-Test ist nicht quadriert.

  2. Die tatsächlichen Teststatistiken sind völlig anders:

Der Wert der Teststatistik für a χ2 ist:

woχ2=i=1n(OiEi)2Ei=Ni=1npi(Oi/Npipi)2

= Pearsons kumulative Teststatistik, die sich asymptotisch einer χ 2- Verteilungnähert. O i = Anzahl der Beobachtungen vom Typ i ; N = Gesamtzahl der Beobachtungen; E i = N p i = die erwartete (theoretische) Häufigkeit von Typ i , die durch die Nullhypothese bestätigt wird, dass der Anteil von Typ i in der Grundgesamtheit p i ist ; n = die Anzahl der Zellen in der Tabelle.χ2χ2OiiNEiNpiiipin

Andererseits ist die Teststatistik für einen Test :z

mitp=x1Z=x1n1x2n2p(1p)(1/n1+1/n2) , wobeix1undx2die Anzahl der "Erfolge" sind, über die Anzahl der Probanden in jeder der Ebenen der kategorialen Variablen, dhn1undn2.p=x1+x2n1+n2x1x2n1n2

Diese Formel scheint auf der Binomialverteilung zu beruhen.

Diese beiden Teststatistiken unterscheiden sich deutlich und führen zu unterschiedlichen Ergebnissen für die eigentliche Teststatistik sowie für die p- Werte : 5.8481für den und für den z-Test mit 2,4183 2 = 5,84817 (danke, @ mark999 ). Der p- Wert für den χ 2 -Test ist , während für den z-Test ist . Der Unterschied erklärt sich durch zweiseitiges gegenüber einseitigem : 0.01559 / 2 = 0.007795 (danke @amoeba).χ22.41832.41832=5.84817χ20.015590.00770.01559/2=0.007795

Auf welcher Ebene sagen wir also, dass sie ein und dasselbe sind?


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

Antworten:


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
Durch die Nutzung unserer Website bestätigen Sie, dass Sie unsere Cookie-Richtlinie und Datenschutzrichtlinie gelesen und verstanden haben.
Licensed under cc by-sa 3.0 with attribution required.