



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




This is a summary of the material that we’ve covered on contingency tables.
There are many situations in quantitative linguistic analysis where you will be inter- ested in the possibility of association between two categorical variables. In this case, you will often want to represent your data as a contingency table. Here’s an example from a project by Roger Levy: Parallelism in phrase coordination, [[NP1] and [NP2]]. I was interested in whether NP and NP2 tended to be similar to each other. As one instance of this, I looked at the patterns of PP modification of each NP (whether the NP had a PP modifier or not) in the Brown and Switchboard corpora, and came up with contingency tables like this: Brown Switchboard NP2 NP hasPP noPP hasPP noPP NP1 hasPP 95 52 NP1 hasPP 78 76 noPP 174 946 noPP 325 1230 Odds and odds ratios Given a contingency table of the form
y 1 y 2 X x 1 n 11 n 12 x 2 n 21 n 22
one of the things that’s useful to talk about is how the value of one variable affects the distribution of the other. For example, the overall distribution of Y is
P (y 1 ) = (^) n 11 +nn^1112 ++nn^2121 +n 22 P (y 2 ) = (^) n 11 +nn^1212 ++nn^2221 +n 22
Alternatively we can speak of the overall odds of y 1 versus y 2 :
P (y 1 ) P (y 2 )
n 11 +n 21 n 11 +n 12 +n 21 +n 22 n 12 +n 22 n 11 +n 12 +n 21 +n 22
n 11 + n 21 n 12 + n 22
If X = x 1 , then the odds for Y are just ΩY 1 = n n^1112. If the odds of Y for X = x 2 are greater than the odds of Y for X = x 1 , then the outcome of X = x 2 increases the chances of Y = y 1. We can express the effect of the outcome of X on the odds of Y by the odds ratio (which turns out to be symmetric between X, Y ):
θ =
n 11 /n 12 n 21 /n 22
n 11 n 22 n 12 n 21
An odds ratio θ = 1 indicates no association between the variables. For the Brown and Switchboard parallelism examples:
θBrown = 9552 ××^946174 = 9. 93 θSwbd = 78325 ×^1230 × 76 = 3. 88
So the presence of PPs in left and right conjunct NPs seems more strongly intercon- nected for the Brown (written) corpus than for the Switchboard (spoken).
Take a binary variable X, let its possible values be 0 and 1. (e.g., coin flip: heads=1, tails=0; NP conjunct: hasPP=1, noPP=0,... ) Call p its probability of outcome 1. (This is called a Bernoulli random variable with parameter p.) Suppose we take a variable Y to be the sum of four such Bernoulli random variables Xi, where all the Xi are independent and each has the same parameter p. By counting, the probability distribution of Y is:
This is the basis for the dof in both the χ^2 and G^2 tests below.
Hypothesis testing typically goes like this: think up a specific, relatively simple model for your data. Call this the null hypothesis H 0. Contrast that with a more general model for your data, of which H 0 is a special case. Call this more general model HA, the alternative hypothesis. You will then calculate some statistic of your data based on H 0 with respect to HA. That statistic will have some probability distribution on the assumption that H 0 is correct. If the value of the statistic likelihood under H 0 is low enough, reject H 0 in favor of the more general HA.
With this test, the statistic you calculate for your data D is the likelihood ratio
max P (D; H 0 ) max P (D; HA)
that is: the ratio of the maximum data likelihood under H 0 to the maximum data likelihood under HA. This requires that you explicitly formulate H 0 and HA. The quantity −2 log Λ∗^ is distributed like a chi-squared distribution [see below] with de- grees of freedom equal to the difference in the the number of free parameters in HA and H 0. So this value can be evaluated against the χ^2 distribution to see whether the null hypothesis should be rejected. [Danger: don’t apply this test when expected cell counts are low, like < 5.]
Apply this test to all sorts of contingency tables, if you have a model with k parameters that predicts expected values Eij for all cells. You calculate the X^2 statistic:
∑
ij
[nij − Eij ]^2 Eij
In the chi-squared test, HA is the model that each cell in your table has its own parameter pi in one big multinomial distribution. Therefore, if your contingency table has n cells, then the difference in the number of free parameters between HA and H 0 is n − k − 1. Correspondingly, you can look up the p-value of your X 2 statistic for the χ^2 distribution with n − k − 1 degrees of freedom. [Note that the distribution is a mathematical curve, which is different from the statistic, which is a test.] [Danger: don’t apply this test when expected cell counts are low, like < 5.]
This test applies to a 2-by-2 contingency table:
y 1 y 2 X x 1 n 11 n 12 n 1 ∗ x 2 n 21 n 22 n 2 ∗ n∗ 1 n∗ 2 n
H 0 is the model that all marginal totals are fixed, but that the individual cell totals are not – alternatively stated, that the individual outcomes of X and Y are independent. [H 0 has one free parameter – why?] HA is the model that the individual outcomes of X and Y are not independent. With Fisher’s exact test, you directly calculate the exact likelihood of obtaining a result as extreme or more extreme than the result that you got. [Since it is an exact test, you can use Fisher’s exact test regardless of expected and actual cell counts.]