Stat 101 – Lecture 40
Categorical Data
• National Opinion Research
Center’s General Social Survey
• In 1996 a sample of 1895 adults in the U.S. were asked the question
“When is premarital sex wrong?”
The participants were also asked with what religion they were affiliated.
1
When is Premarital Sex Wrong?
Class
Always
Almost Always
Sometimes
Never
Total
Count
452
183
429
831
1895
%
23.85
9.66
22.64
43.85
100
2
Bar Chart
750
500
250
3
Stat 101 – Lecture 40
Goodness-of-Fit
• Are respondents choosing the four responses equally?
• If respondents are choosing the four responses equally we would expect to see 25% of
1895 in each category.
4
When is Premarital Sex Wrong?
Class
Always
Almost Always
Sometimes
Never
Total
Count
452
183
429
831
1895
Expected
473.75
473.75
473.75
473.75
1895
5
Chi-Square Statistic
2 df
=
(
Obs
−
Exp
) 2
Exp
=
# of categories
−
1
6
Stat 101 – Lecture 40
Chi-Square Statistic
χ 2 = ∑
(
Obs
−
Exp
)
2
Exp
χ 2
+
=
(
452 − 473 .
75
) (
183 − 473 .
75
) 2
(
429
473 .
75
−
473 .
75
) (
831
473 .
75
−
473 .
75
)
2
473 .
75 473 .
75
χ 2 df
=
1 .
00
+
178 .
44
+
4
= # of categories − 1
.
23
=
+
269 .
40
3
=
453 .
07
7
Chi-Square Statistic
• The value of the Chi-Square statistic is extremely large.
• The corresponding P-value is less than 0.005.
8
Interpretation
• We should reject the hypothesis that people are choosing the four answers equally.
• The respondents are choosing
Never much more often than expected if they were choosing equally.
9
Stat 101 – Lecture 40
Religion
Catholic
Jewish
Protestant
None
Other
Total
When is Premarital Sex Wrong?
Always Almost
Always
Sometimes
62 37 120
0
355
20
15
452
3
117
13
13
183
14
227
45
23
429
Never Total
226
34
384
147
445
51
1083
225
40
831
91
1895
10
When is Premarital Sex Wrong?
Religion
Catholic
Jewish
Protestant
None
Other
Always Almost
Always
Sometimes
13.9% 8.3% 27.0%
0.0%
32.8%
8.9%
16.5%
5.9%
10.8%
5.8%
14.3%
27.4%
21.0%
20.0%
25.3%
Never
50.8%
66.7%
35.4%
65.3%
43.9%
Total
100%
100%
100%
100%
100%
11
Mosaic Plot
12
Stat 101 – Lecture 40
Test of Independence
• Is attitude toward premarital sex independent of religion?
• If attitude toward premarital sex is independent of religion we expect to see the same proportions in each religion that we see for the whole.
13
When is Premarital Sex Wrong?
Class
Always
Almost Always
Sometimes
Never
Total
%
23.85
9.66
22.64
43.85
100
Catholic
106.13
42.99
100.75
195.13
445
14
Expected
• Need to do this for each religion.
• Compare observed counts to expected counts with the chisquare statistic.
15
Stat 101 – Lecture 40
Chi-Square Statistic
χ 2 =
(
Obs
−
Exp
) 2
Exp
χ 2 df df
=
=
157 .
017
(# of rows
=
12
−
1 )(# of columns
−
1 )
16
Chi-Square Statistic
• The value of the Chi-Square statistic is extremely large.
• The corresponding P-value is less than 0.005.
17
Interpretation
• We should reject the hypothesis that attitude toward premarital sex and religion are independent.
• Attitudes toward premarital sex are associated with religion.
18