Docsity

Chi-square Test & Models for Independence in Two-way Tables, Study notes of Statistics

Toggle sidebar
bg1
Inference for Two-way Tables
•Two-way table for categorical dataset;
•Chi-square test for two-way table;
•Models for two-way tables;
–Examining independence between
variables;
–Comparing several populations.
1
Example: Background music and consumer behavior
In a study conducted in a Northern Ireland
supermarket, researchers counted the number of
bottles of French, Italian, and other wine
purchased while shoppers were subject to one of
three “treatments”: no music, French accordion
music, and Italian string music.
The following two-way table summarizes the
data:
Music
Wine None French Italian Total
French 30 39 30 99
Italian 11 1 19 31
Other 43 35 35 113
Total 84 75 84 243
2
Example (cont.)
The table of counts looks suspiciously like the joint
distribution tables we studied earlier. Indeed, from
these counts, we can ascertain the (empirical) joint
distribution, marginal distributions, and conditional
distributions of wine type and music type:
Music
Wine None French Italian Total
French 0.123 0.160 0.123 0.407
Italian 0.045 0.004 0.078 0.128
Other 0.177 0.144 0.144 0.465
Total 0.346 0.309 0.346 1.000
We are interested in determining whether there is
relationship between the row variable (wine type) and
the column variable (music type).
If this were the true distribution, then the answer
would be clear: music and wine are not independent,
so there is a relationship.
However, this table is random, and we want to know
whether or not music and wine are independent under
the true distribution. This requires a statistical test.
3
The χ2-test for a r×cTable
Hypotheses
•H0: the row and column variables are
independent (i.e. there is no relationship
between the two).
•Ha: the row and column variables are
dependent.
Intuition for the Test
Suppose H0is true, and the two variables are
independent. What counts would we expect to
observe?
Recall that under the independence assumption,
P(A, B) = P(A)P(B)
Thus, for each cell, we have
Expected Cell Count = row total ×col total
total count
Our test will be based on a measure of how far
the observed table is from the expected table.
4
pf3

Partial preview of the text

Download Chi-square Test & Models for Independence in Two-way Tables and more Study notes Statistics in PDF only on Docsity!

Inference for Two-way Tables

  • Two-way table for categorical dataset;
  • Chi-square test for two-way table;
  • Models for two-way tables;
    • Examining independence between variables;
    • Comparing several populations.

1

Example: Background music and consumer behavior In a study conducted in a Northern Ireland supermarket, researchers counted the number of bottles of French, Italian, and other wine purchased while shoppers were subject to one of three “treatments”: no music, French accordion music, and Italian string music. The following two-way table summarizes the data: Music Wine None French Italian Total French 30 39 30 99 Italian 11 1 19 31 Other 43 35 35 113 Total 84 75 84 243

2 Example (cont.)

The table of counts looks suspiciously like the joint distribution tables we studied earlier. Indeed, from these counts, we can ascertain the (empirical) joint distribution, marginal distributions, and conditional distributions of wine type and music type:

Music Wine None French Italian Total French 0.123 0.160 0.123 0. Italian 0.045 0.004 0.078 0. Other 0.177 0.144 0.144 0. Total 0.346 0.309 0.346 1.

We are interested in determining whether there is relationship between the row variable (wine type) and the column variable (music type).

If this were the true distribution, then the answer would be clear: music and wine are not independent, so there is a relationship.

However, this table is random, and we want to know whether or not music and wine are independent under the true distribution. This requires a statistical test.

The χ^2 -test for a r × c Table

Hypotheses

  • H 0 : the row and column variables are independent (i.e. there is no relationship between the two).
  • Ha: the row and column variables are dependent. Intuition for the Test Suppose H 0 is true, and the two variables are independent. What counts would we expect to observe? Recall that under the independence assumption, P (A, B) = P (A)P (B) Thus, for each cell, we have

Expected Cell Count = row total^ ×^ col total total count Our test will be based on a measure of how far the observed table is from the expected table.

Example (cont.)

For the supermarket example, the expected counts are:

Music Wine None French Italian Total French 34.22 30.56 34.22 99 Italian 10.72 9.57 10.72 31 Other 39.06 34.88 39.06 113 Total 84 75 84 243

The X^2 (Chi-Squared) Statistic

To measure how far this expected table is from the observed table, we will use the following test statistic:

X^2 =

all cells

(Observed − Expected)^2 Expected

5

The χ^2 Distribution

Under H 0 , the X^2 test statistic has an approximate χ^2 distribution with (r − 1)(c − 1) degrees of freedom, denoted χ^2 (r−1)(c−1). Why (r − 1)(c − 1)? Recall that our “expected” table is based on some quantities estimated from the data: namely the row and column totals. Once these totals are known, filling in any (r − 1)(c − 1) undetermined table entries actually gives us the whole table. Thus, there are only (r − 1)(c − 1) freely varying quantities in the table.

6

What does the χ^2 distribution look like?

0 10 20 30 40 50

Chi−Squared Densities

X^

Density

Degrees of Freedom (^15) (^1020) 30

  • Unlike the Normal or t distributions, the χ^2 distribution takes values in (0, ∞).
  • As with the t distribution, the exact shape of the χ^2 distribution depends on its degrees of freedom.

p-Value for the χ^2 -Test

If the observed and expected counts are very different, X^2 will be large, indicating evidence against H 0. Thus, the p-value is always based on the right-hand tail of the distribution. There is no notion of a two-tailed test in this context. The p-value is therefore

P (χ^2 (r−1)(c−1) ≥ X^2 )

Recall that X^2 has an approximate χ^2 (r−1)(c−1) distribution. When is the approximation valid? For any two-way table larger than 2 × 2, we require that the average expected cell count is at least 5 and each expected count is at least one. For 2 × 2 tables, we require that each expected count be at least 5.