Professional Documents
Culture Documents
Week9 Chi Square Test of Independence2
Week9 Chi Square Test of Independence2
Data
Quantitative Qualitative
Discrete Continuous
EPI809/Spring 2008 2
Qualitative Data
1. Qualitative Random Variables Yield
Responses That Can Be Put In Categories.
Example: Gender (Male, Female)
2. Measurement or Count Reflect # in Category
3. Nominal (no order) or Ordinal Scale (order)
4. Data can be collected as continuous but
recoded to categorical data. Example
(Systolic Blood Pressure - Hypotension,
Normal tension, hypertension )
EPI809/Spring 2008 3
Hypothesis Tests
Qualitative Data
Qualitative
Data
2 or more
1 pop. pop.
Proportion Independence
2 pop.
EPI809/Spring 2008 4
Hypothesis Tests
Qualitative Data
Qualitative
Data
2 or more
1 pop. pop.
Proportion Independence
2 pop.
EPI809/Spring 2008 5
Chi Square Test of Independence
• A measure of association similar to the correlations
we will see later.
• T tests or Pearson and Spearman are not applicable if
the data are at the nominal level of measurement.
• Chi Square is used for nominal data placed in a
contingency table.
– A contingency table is a two-way table showing the
contingency between two variables where the variables
have been classified into mutually exclusive categories
and the cell entries are frequencies.
Test of Independence
2
EPI809/Spring 2008 7
Test of Independence
2
Contingency Table
1.Shows # Observations From 1 Sample
Jointly in 2 Qualitative Variables
Levels of variable 2
Residence
Disease Urban Rural Total
Status
Disease 63 49 112
No disease 15 33 48
Total 78 82 160
Levels of variable 1
EPI809/Spring 2008 8
Test of Independence
2
EPI809/Spring 2008 9
Test of Independence
2
ch
nij E nij
2
Expected
2
all cells ch
E n ij
count
EPI809/Spring 2008 10
Test of Independence
2
ch
nij E nij
2
Expected
2
all cells ch
E n ij
count
Rows Columns
Degrees of Freedom: (r - 1)(c - 1)
EPI809/Spring 2008 11
2 Test of Independence
Expected Counts
1.Statistical Independence Means Joint
Probability Equals Product of Marginal
Probabilities
2.Compute Marginal Probabilities & Multiply
for Joint Probability
3.Expected Count Is Sample Size Times
Joint Probability
EPI809/Spring 2008 12
An Example
• Suppose that the state legislature is considering
a bill to lower the legal drinking age to 18. A
political scientist is interested in whether there
is a relationship between party affiliation and
attitude toward the bill. A random sample of
150 registered republicans and 200 registered
democrats are asked their opinion about the
proposed bill. The data are presented on the
next slide.
Political Party and
Legal Drinking Age Bill
Attitude Toward Bill
For Undecided Against Total
Republican 38 17 95 150
Democrat 92 18 90 200
Republican 38 17 95 150
55.7
Democrat 92 18 90 200
Democrat 92 18 90 200
74.3 20 105.7
Democrat 92 18 90 200
74.3 20 105.7 57.2%
The numbers in Green are the percentage of the total for each Party.
The Expected Values
• The expected values for each cell are also
equal to the percentage of each party for the
column total.
• For example, Republicans were 42.8% of the
total persons surveyed
• If 130 people were in favor of the bill, then
42.8% of them should be Republican (55.7), if
there is no relationship between the variables
Calculating the Chi Square Statistic
(38 55.7) 2
(17 15) 2 (95 79.3) 2
55.7 15 79.3