Nominal Data - University of Pennsylvania

Download Report

Transcript Nominal Data - University of Pennsylvania

Lecture 15: Tues., Mar. 2
• Inferences about Linear Combinations of
Group Means (Chapter 6.2)
• Chi-squared test (Handout/Notes)
• Thursday: Simple Linear Regression
(Chapter 7)
Review of One-way layout
• Assumptions of ideal model
– All populations have same standard deviation.
– Each population is normal
– Observations are independent
• Planned comparisons: Usual t-test but use all groups to
estimate  . If many planned comparisons, use Bonferroni
to adjust for multiple comparisons
• Test of H0 : 1  2    I vs. alternative that at least
two means differ: one-way ANOVA F-test
• Unplanned comparisons: Use Tukey-Kramer procedure to
adjust for multiple comparisons.
Case Study 5.1.2: Spock
Conspiracy Trial
• In 1968, Dr. Spock was tried in U.S. District Court
of Boston on charges of conspiring to violate
Selective Service Act by encouraging young men
to resist being drafted into military service.
• Defense challenged method by which jurors were
selected, claiming that women – many of whom
had raised children according to popular methods
developed by Dr. Spock - were underrepresented
• Venire for trial contained only one woman.
• Defense argued that judge in trial had a history
had a history of venires in which women were
systematically underrepresented.
Data for Spock Conspiracy Trial
• Percent of women in recent 30-juror venires for
Spock Trial judge and six other Boston area
district judges (A,B,C,D,E,F). Seven groups
(judges) in one-way layout. Data in spock.JMP.
• Key question: How does the mean percentage of
women for Spock Trial judge compare to the
average of the mean percentage of women for the
other six judges, i.e., what is
Spock 
 A   B  C   D   E   F
6
Inference about Linear
Combinations of Group Means
• Parameter of interest:   C11  C22   CI I
1
C

1
,
C

C

C

C

C

C


2
3
4
5
6
7
For Spock study, 1
6
• Point estimate: g  C1Y1  C2Y2   CIYI
2
2
2
• Standard Error:
C
C
C
SE( g )  s p
1
n1

2
I
nI
• 95% Confidence Interval for  : g  t.975,nI * SE( g )
• Test of H0 :    *, Ha :    *: For level .05 test,
reject H 0 if and only if  * does not belong to
the 95% confidence interval.
n2

Oneway Analysis of PERCENT By JUDGE
PERCENT
45
35
25
15
5
A
B
C
D
E
F
S PO CK 'S
JUDG E
Means and Std Deviations
Level
Number
A
B
C
D
E
F
SPOCK'S
5
6
9
2
6
9
9
Mean
Std Dev Std Err Mean Lower 95%
34.1200 11.9418
33.6167
6.5822
29.1000
4.5929
27.0000
3.8184
26.9667
9.0101
26.8000
5.9689
14.6222
5.0388
5.3405
2.6872
1.5310
2.7000
3.6784
1.9896
1.6796
19.29
26.71
25.57
-7.31
17.51
22.21
10.75
Upper 95%
48.948
40.524
32.630
61.307
36.422
31.388
18.495
Oneway Anova
Summary of Fit
Rsquare
Adj Rsquare
Root Mean Square Error
Mean of Response
Observations (or Sum Wgts)
0.50826
0.432608
6.914209
26.58261
46
Analysis of Variance
Source
DF
Sum of Squares
Mean Square
F Ratio
Prob > F
JUDGE
6 1927.0808 321.180 6.7184 <.0001
Error
39 1864.4453
47.806
C. Total 45 3791.5260
Spock Trial Analysis
Linear Combination of Interest:    Spock 's 
 A   B  C   D   E   F
6
Point Estimate:
34 .12  33 .62  29 .10  27 .00  26 .97  26 .80  14 .62
g  14 .62 
 17 .42
6
Standard Error:
12 (1 / 6) 2 (1 / 6) 2 (1 / 6) 2 (1 / 6) 2 (1 / 6) 2 (1 / 6) 2
SE ( g )  6.91






 2.62
9
6
9
2
6
9
9
 17 .42  t 45 6 (. 975 ) * 2.62

95% Confidence Interval for :
t 30 (. 975 )  2.042
Rounding the degrees of freedom down to nearest entry on Table A.6,
 ( 12.07,22.77)
Approximate 95% H
Confidence
:   0 Interval:
H :   17
0 .42  2.042* 2.62H
0
a
0
Hypothesis test of
vs.
at level 0.05: Reject
since 0 is not in the
95% confidence interval.
Conclusion: There is evidence that the mean percent of women in Spock’s trial judge’s
venire is less than the average of the mean percent of women in the other six trial judges’
venires. A 95% confidence interval for the difference between the mean percent of
percent of women in Spock’s trial judge’s venire and the average of the mean percent of
women in the other six trial judges’ venires is (-12.07, -22.77).
Linear Combinations: Comparing
Rates
• In mice diet study, we are interested in the rate of
increase in lifetime for each additional kilocalorie
of reduced diet.
• For example we are interested in comparing rate
of increase in lifetime associated with reduction


(
from 50 to 40 kcal/wk (50  40) ) vs. rate of
increase in lifetime associated
with reduction from


85 to 50 kcal/wk ( (85  50) )
 N / R 50   N / N 85  N / R 40   N / R 50



•
N / R 40
N / R 50
35
N / R 50
N / N 85
10
45
1
1
 N / R 50   N / N 85   N / R 40
350
35
10
Oneway Analysis of LIFETIME By DIET
Oneway Anova
Summary of Fit
Rsquare
Adj Rsquare
Root Mean Square Error
0.454275
0.44632
6.678239
Means and Std Deviations
Level
N/N85
N/R40
N/R50
NP
R/R50
Lopro
Number
Mean
Std Dev
Std Err Mean
Lower 95%
Upper 95%
57
60
71
49
56
56
32.6912
45.1167
42.2972
27.4020
42.8857
39.6857
5.12530
6.70341
7.76819
6.13370
6.68315
6.99169
0.67886
0.86541
0.92192
0.87624
0.89307
0.93430
31.331
43.385
40.458
25.640
41.096
37.813
34.051
46.848
44.136
29.164
44.675
41.558
45
1
1
 N / R 50 
 N / N 85 
 N / R 40
350
35
10
45
1
1
* 42 .3 
* 32 .7 
* 45 .1  0.0057 months/(kcal/wk)
Point Estimate: g 
350
35
10
( 45 / 350 ) 2
( 1 / 35 ) 2
( 1 / 10 ) 2
SE ( g )  6.68


 0.1359
Standard Error:
57
60
t
(. 975 )  t 71
(. 975 )  1 .984
Parameter of Interest:  
343
100
Degrees of Freedom:
95% Confidence Interval:
H.1
:
:,2.
00 6) months/(kcal/wk)
0 3
 0.0 0 5 7 1.9 8 4* 0
5 90( 2.7H
0 a2 0
69
Hypothesis test of
vs.
does not reject at 0.05 level since 0 is in 95%
confidence interval.
Conclusion: No evidence of a difference in rates of increase in lifetime associated with
reduction of diet from 85 kcal/wk to 50 kcal/wk compared to reduction in diet from 50
kcal/wk to 40 kcal/wk.
Populations of Nominal Data
• So far we have focused on comparing populations
of interval data (e.g., heights, scores, incomes)
• We now consider comparing populations of
nominal data. Nominal data are data that are
categories. Examples:
– Candidate person voted for (Bush or Gore)
– Color of M&Ms (brown, yellow, red, orange, green or
blue)
• A population of nominal data with k categories
can be described by the proportion in each
category, p1 in category 1, p2 in category 2, …, pk
k
in category k, (i1 pi  1 ) , e.g., population of
M&M’s is supposed to have
pbrown  pyellow  pred  pblue  0.2, pgreen  porange  0.1
One Sample Test for Nominal Data
• Analogue of one sample problem with
interval population: Take random sample of
size n from a population of nominal data.
We want to test whether population
frequencies are p1  p1*, p2  p2*,, pk  pk *
H 0 : p1  p1*, p2  p2 *,, pk  pk *
H a : at least oneof pi  pi * (i  1,...,k )
SAT example
• People sometimes say that “b” and “c”
answers occur most frequently on multiple
choice tests. To see if there is any evidence
that the answers do not occur with equal
frequency, a random SAT exam was
selected from The College Board, 10 SATs,
New York: College Entrance Examination
Board. H0 : pa  pb  pc  pd  pe  0.2
H a : at least one of pa , pb , pc , pd , pe  0.2
Data (sat.JMP)
1. d
2. d
3. b
4. b
5. c
6. e
7. b
8. a
9. a
10. b
11. c
12. b
13. e
14. e
15. c
16. d
17. a
18. c
19. c
20. b
21. b
22. b
23. c
24. b
25. c
26. a
27. c
28. e
29. e
30. b
31. d
32. d
33. b
34. e
35. e
36. c
37. e
38. c
39. d
40. e
41. e
42. a
43. a
44. a
45. b
46. e
47. d
48. b
49. d
50. b
51. a
52. a
53. c
54. c
55. a
56. c
57. e
58. d
59. c
60. b
61. b
62. d
63. e
64. b
65. d
66. e
67. b
68. d
69. c
70. c
71. a
72. c
73. b
74. d
75. e
76. a
77. c
78. c
79. d
80. d
81. b
82. d
83. d
84. e
85. b
Chi-squared Test
Category
Observed Frequency
Expected Frequency under
H0
1
f1
e1 
p1* * n
2
f2
*
e2  p 2 * n
...
k
fk
ek  p k* * n
2
(
f

e
)
 2  i1 i i
ei
k
• Chi-squared test statistic:
• Reject H 0 for large values of  2 . Critical value
2

for level .05 test is .95 quantile of
distribution
with k-1 degrees of freedom (Table A.3)
• Test is only valid if expected frequencies in each
cell are 5 or more. When necessary, cells should
be combined in order to satisfy this condition.
Chi-Squared Test for SAT data
Letter
Observed Frequency Expected Frequency
A
B
C
D
E
Total
12
22
19
17
15
 2  3.42
85*0.2=17
85*0.2=17
85*0.2=17
85*0.2=17
85*0.2=17
(ObservedExpected)2/Expected
1.47
1.47
0.24
0.00
0.24
3.42
The
test statistic
. The critical value for rejecting at the 0.05 level is
H0
 42 (. 95)  9.49
. Since 3.42<9.49, we do not reject
. There is no evidence that the
letters are not random on the SAT.
Chi-Squared Test in JMP
• (For the SAT example)
• Method I (list all observations in sample): Create a column
for answer and list the sample. Then click Analyze,
Distribution, put column with answer in Y, click OK, then
click red triangle next to answer, click Test Probabilities
and then input the hypothesized probabilities (0.2 for each
category for SAT example). Then click OK. The row
Pearson gives the chi-squared statistic and the p-value.
• Method II (list frequencies for each category): Create a
column for each answer (a,b,c,d,e) and another column
frequency which contains the frequency of each answer.
Then click Analyze, Distribution, put column with answer
in Y and put column with frequency in Freq and click OK.
Follow above instructions.
Distributions
Answers
e
e
d
d
c
c
b
b
a
a
Frequencies
Level
a
b
c
d
e
Total
Count
Prob
12
22
19
17
15
85
0.14118
0.25882
0.22353
0.20000
0.17647
1.00000
5 Levels
Test Probabilities
Level
a
b
c
d
e
Estim Prob
Hypoth Prob
0.14118
0.25882
0.22353
0.20000
0.17647
0.20000
0.20000
0.20000
0.20000
0.20000
Test
Likelihood Ratio
Pearson
No evidence against
=0.4914.
ChiSquare
DF
Prob>Chisq
3.4568
3.4118
4
4
0.4845
0.4914
H 0 : p a  p b  p c  p d  p e  0 .2
, p-value
Random numbers experiment
• When selecting random numbers (e.g., for a
random sample or randomized experiment), you
should always use a random number generator or a
random number table. People are very bad at
picking random numbers themselves.
• Experiment: Everybody pick a random whole
number between 1 and 10. We’ll then survey the
class and test whether people’s “random” numbers
are really random.
Chi-squared test for random
numbers experiment
Number
1
2
3
4
5
6
7
8
9
10
Observed
Expected
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
0.1*n =
2 
Critical value: Reject
H 0 : p1  p2  ...  p10  0.1
if
 2   92 (. 95 )  16 .92
M&M’s
• According to the M&M’s web site, the color
distribution in peanut butter M&M’s is 20%
brown, 20% yellow, 20% red, 20% blue,
10% green and 10% orange. Test
H 0 : pbrown  pyellow  pred  pblue  0.2, pgreen  porange  0.1
H a : at least oneof aboveprobabilties is not true.
Chi-squared test for M&Ms
Color
Brown
Yellow
Red
Blue
Green
Orange
Observed
Expected
0.2*n =
0.2*n =
0.2*n =
0.2*n =
0.1*n =
0.1*n =
2 
Critical value: Reject
 2   52 (. 95 )  11 .07
H 0 : p brown  p yellow  p red  p blue  0.2, p green  p orange  0.1
if