Download Week 11 notes Inferences concerning variances (Chapter 8), WEEK

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Hardware random number generator wikipedia , lookup

Randomness wikipedia , lookup

Generalized linear model wikipedia , lookup

Probability box wikipedia , lookup

Bootstrapping (statistics) wikipedia , lookup

Confidence interval wikipedia , lookup

Taylor's law wikipedia , lookup

Transcript
Week 11 notes
Inferences concerning variances (Chapter 8),
WEEK 11
page 1
inferences concerning proportions (Chapter 9)
We recall that the sample variance
1
 2 has mean E [ S 2 ]= 2
S 2=
 X i− X
n−1 ∑
i =1
and is thus an unbiased estimator of the population variance  2 . We can not conclude from this
however that the the sample standard deviation S has mean the population standard deviation  . In
fact the sample standard deviation is not an unbiased estimator of the population standard deviation
E [S ]≠
although the bias E [S ]− is slight and goes to 0 for large n.
Using the sample range to estimate  : For samples from a normal population the sample range
random variable R defined by the maximum observation minus the minimum :
R=max i X i−mini X i
has mean equal to a constant d 2=d 2  n (depending on the sample size n ) given in the table on page
282 of the text for small n, times the standard deviation  so R/ d 2 is an unbiased estimator of
 :
E [ R/d 2]= .
We also know that for samples from a normal population, with probability 1− , the chi squared
random variable with parameter =n−1 degrees of freedom, satisfies the inequality
 n−1 S 2
21−/ 2   2 =
 2 / 2
2

where recall unlike the normal or t distributions since the chi-squared is not a symmetric distribution,
both the upper and lower chi-squared critical values are needed. Solving for the population variance,
with probability 1− the above inequality equivalently becomes the
100( 1− )% confidence interval for the (population) variance :
n−1 S 2
n−1S 2
2



.
2/ 2
21− /2
Taking square roots of each member of this inequality gives the corresponding confidence interval for
the population standard deviation. Johnson points out that because the chi-squared distribution is not
symmetric, taking equal tail probabilities as we have done does not yield the optimal (narrowest)
confidence interval nor the best way to test a two sided hypothesis, but to avoid complicated
calculations, the above for convenience is typically used and for moderate sized samples the two are
almost the same.
n
Hypotheses concerning one variance :
Our estimate of the population variance is the sample variance and as this increases so does the
chi-squared statistic which is directly proportional to the sample variance. Thus we are lead to the
hypothesis testing criteria summarized in the table : ( for samples from a normal population )
Critical regions for testing a hypothesis H 0 :  2= 20 for a variance :
Alternative hypothesis
Reject null hypothesis if
2
2
  0
221−
 2 20
22
2
2
2
2
2
2
 ≠ 0
 1− /2 or   /2
EXAMPLE 1 (like HW problems 8.3 and 8.6) Use the data of problem 7.70 b) of the text to estimate
the population standard deviation  1 for bumper guard 1 repair costs in terms of
a) sample standard deviation and b) sample range, then c) find a 99% confidence WEEK 11 page 2
interval for  1 : Recall the bumper guard 1 repair cost data (in dollars) : 107 148 123 165 102 119
a)
2
s1 =598−2/ 15 or s 1=24.451312 is our estimate of  1
b) The sample range is R = 165 – 102 = 63 so using the table on page 282 of the text for d 2=d 2 n
with sample size n = 6 observations, we find for our estimate
R/ d 2=63/2.534 = 24.86 is our estimate of  1 .
c) Using the chi-squared critical values with n-1=5 degrees of freedom =.01 and /2=.005 we
have the 99% confidence interval for the variance :
n−1 S 2
2990−2/3
 n−1 S 2
2990−2/3
2
=
=
178.46766



=
= 7255.66343
2
2
16.75
.412
/ 2
1− / 2
which upon taking square roots yields the corresponding 99% confidence interval for  1

or
n−1 S 2
=
2/ 2
178.46766=13.359178   

n−1 S 2
= =
21− /2
7255.66343 = 85.180182
13.359178    85.180182 .
EXAMPLE 2 problem 8.10 of text (like HW problem 8.12) Test at significance level =.01 the
null hypothesis that diameters of certain bolts have standard deviation
2
2
H 0 :  =.015 inch or equivalently  =.015 =.000225
against the two-sided alternative H a :≠.015 given that a random sample of size 15 has variance
2
s =.00011 : With n-1 = 14 degrees of freedom we compute the chi-squared statistic
2
n−1 S
14.00011
2 =
=
= 6.84 4
2
.000225

which lies between the two relevant chi-squared critical values
2
2
.995 =4.075 and .005 =31.319 .
Thus we should not reject the null hypothesis at significance level .01.
Hypotheses concerning two variances :
For independent random samples from two normal populations with the same variance, we know that
the random variable
2
S
F = 12
S2
has an F distribution with degrees of freedom n 1−1 and n 2−1 in the numerator and denominator
respectively. Writing S 2M for the larger, S m for the smaller of the two variances with corresponding
sample sizes n M and n m , we have the
Critical regions for testing a hypothesis H 0 :  21= 20 for two variances :
Alternative hypothesis
test statistic
Reject null hypothesis if
2
S
 12 22
F = 22
F  F   n2−1 , n1−1
S1
2
S
 12 22
F = 12
F  F   n1−1 , n2−1
S2
S2
 12≠ 22
F = M2
F F  /2  n M −1 , nm−1
Sm
Here we have made use of the relation ( which follows by interchanging the roles WEEK 11 page 3
of the two samples ) :
1
F 1−  1 , 2 =
.
F   2 , 1 
EXAMPLE 3 problem 8.14 of the text (like HW problem 8.15)
With reference to problem 7.68 use the .02 level of significance to test the assumption that the two
populations have equal variances.
Here the alternative hypothesis should not be confused with the one sided alternative of 7.68 since that
hypothesis referred to a claim about the population means (not their variances as is the case here).
Since we have no prior reason to believe the variance of either method is larger, we should use a two
sided alternative . (Furthermore we are not given a table for the F critical value F  =F .02 since the
only tables given are for .01 or .05 so we would need to use a computer program for a one sided test )
Recall the data for trainee scores obtained with the two methods
Method A : 71, 75, 65, 69, 73, 66, 68, 71, 74, 68
Method B: 72, 77, 84, 78, 69, 70, 77, 73, 65, 75
for which we computed the sample variances
1
102
s12= 1 2525 2123 24 222124 22 2 =
9
9
1 2 2
262
2
2
2
2
2
2
2
2
2
s 2= 2 3 10 4 5 4 3 1 9 1  =
9
9
Thus we use the F statistic, the ratio of the largest over the smallest sample variance :
F=
S 2M S 22 262 131
= =
=
=2.56863
S 2m S 12 102 51
with critical value
F  / 2=F .01  2=9, 1=9=5.35
from table 6 b) of appendix B. Since our statistic is not larger than the critical value we
can not reject the null hypothesis at level .02.
Inferences concerning proportions (Chapter 9 )
The (sample) proportion of times an event occurs in n independent identical
(Bernoulli) trials is the binomial random variable X divided by the sample size n which
is the number of times the event occurs relative to the number of trials and this sample
proportion we use to estimate the population proportion which is the actual binomial
parameter p :
p =
X number of times the event occurs in n trials
=
n
n
Note since a binomial random variable is a sum of 0 or 1 valued Bernoulli random
variables :
X =∑ X i where X i =1 if the event occurs (success) on the i th trial , X i=0 else
i
we have that the sample proportion is just the sample mean of these Bernoulli random
variables having expected value the actual population mean p= X :
i
p = x has mean E [ p ]= X = p .
WEEK 11
page 4
Recall that the mean and variance of the binomial random variable X are np and np(1-p)
respectively from which we find that the sample proportion has mean
i
E [ p ]=E [
X
np
]= = p (as agrees with the above)
n
n
and standard deviation



X
np 1− p
p1− p 
]=
=
=
where =  p 1− p 
2
n
n
n
n
=  p 1− p  is the standard deviation of a single Bernoulli 0 or 1 valued
 p= V [
(that is where
random variable).
Confidence intervals for proportions :
For small sample sizes : Since the sample proportion is a discrete random variable, it
may be impossible to get an interval for which the degree of confidence is exactly
100( 1− )% . For small sample sizes the confidence interval may be determined
directly from the cumulative distribution function for binomial random variables given
in table 1 of appendix B. With probability 1− the binomial random variable X should
satisfy
x 0  p X x 1  p ,
where for example for n = 20 and for fixed p to get a 95% confidence interval using
table 1 one solves for the largest integer x 0 satisfying the inequality
x0
B x 0 ;20 , p=∑ bk ;n , p= P X ≤ x 0 ≤/2=.025
k=0
and for the smallest integer x 1 satisfying
n=20
1−B x 1−1 ;20 , p= ∑ bk ;n , p= P x 1≤ X ≤/2=.025
k=x 1
Having solved x 0 and x 1 for different values of p one then goes backwards to solve
for p for given value of X . This is done for different sample sizes in table 9(a) and 9 (b)
in the appendix B where it is x 0 /n and x 1 /n that are plotted against p with the top
values of x/n going with the values of p on the right side and the bottom values of x/n
going with the values of p on the left side of the graph. To justify this procedure
note that since the graphs of x 0  p and x 1  p are both increasing functions, we can
apply their inverse functions to the inequality x 0  p X x 1  p which holds with
probability 1− obtaining (also with probability 1− ) :
−1
−1
x 1  X  p px 0  X  p ,
but for fixed value of x= X  p this is exactly the procedure that Johnson discusses.
Small sample hypothesis tests for proportions : By the relation between confidence
intervals and two-sided hypothesis tests, this method gives a rejection region for the
small sample two sided test i.e. we reject the null hypothesis if the null hypothesis value
−1
of p falls outside of the interval x −1
1  X  p px 0  X  p . Similar regions for one
sided tests are obtained if we solve for x 0 ( or x 1 ) using probability  instead of
/2 above.
WEEK 11
page 5
For large sample sizes we have by the normal approximation to the binomial (special
case of the central limit theorem ) that with probability 1−
−z  /2  Z =
X −np
=
 np 1− p 
 X / n− p
 z / 2
 p1− p/n
This is a quadratic inequality in the variable p which can be converted into two quadratic
equations giving the upper and lower bounds for p (see problem 9.14 of text). As this
gets complicated it is common to instead estimate p in the denominator by the sample
proportion x/n yielding the
approximate 100( 1− )% large sample confidence interval for p :
p 1− p 
p  1− p 
x
x
x
n
− z / 2

n
 p 
n
 z  /2

n
where p=
n
When the sample proportion is used to estimate p, with probability 1−
| X / n− p | is bounded by the maximum error
E = z / 2

the difference
p 1− p 
n
which we can estimate by using the sample proportion x/n in place of p.
EXAMPLE 1 of Chapter 9 : Problem 9.3 of text (like HW 9.1)
In a random sample of 400 industrial accidents, it was found that 231 were due at least
partially to unsafe working conditions. Construct a 99% confidence interval for the
corresponding true proportion using
(a) Table 9;
(b) the large sample confidence interval formula
a) Here x/n = 231/400 = .5775 is greater than .5 so we use the values of x/n on the top
of Table 9 (b) which go with the values of p on the right side of the graph. Looking at
the two curves for n = 400 with x/n just to the right of .58 gives approximately the
99% confidence interval : [.52, .64]
for p
b) With z .005 =2.575 and 1−231 /400=169 /400=13/20 2 the large sample interval is
.5775±2.575  23113/400/20=.5775±.063597
or
[.5139, .6411]
EXAMPLE 2 Problem 9.4 of text (like HW 9.2) What can we say with 95% confidence
about the maximum error in exercise 9.3 above if we use the sample proportion
( 231/400 ) to estimate p ?
Replacing p by 231/400 and using z .025=1.96 the maximum error is
z  / 2  p1− p/  n ≈ 1.96  231 13 /400/20=.048408
WEEK 11
page 6
Sample size determination for estimating a proportion given a maximum error :
Given a bound on the maximum error
z / 2

p 1− p
≤ E , we can re-write this inequality as
n
z  / 2  p1− p/ E≤  n
2
 
z
n≥ p 1− p  /2
E
or squaring both sides :
gives the sample size needed
If we know nothing about the parameter p , we still know from calculus that
p 1− p≤
1
4
so that we are always safe in taking the sample size n so large that
2
 
1 z / 2
n≥
4 E
,
but we can do better if we know a definite upper bound on p < .5 which we can plug into
p(1- p) to get a bound on this expression. (Similarly a lower bound on p > .5 yields an
upper bound on 1-p which gives a corresponding bound on p(1-p) ) .
EXAMPLE 3 problems 9.12 of text ( like HW 9.10 ) and 9.13 (like HW 9.11)
Suppose that we want to estimate what percentage of all drivers exceed the 55 mph
speed limit on a certain stretch of road.
a) problem 9.12 : How large a sample will we need to be at least 99% confident that the
error of our estimate (our estimate being the sample percentage ) is at most 3.5% ?
We have that z .005=2.575 , E≤3.5 %=.035 and using the bound
2
 
1 z / 2
n≥
4 E
gives
2
   
2
1 z / 2
1 2.575
n≥
=
=1353.19 or n≥1354 .
4 E
4 .035
b) problem 9.13 : How would the required sample size be affected if it is known that the
percentage to be estimated is at most 40% ?
p≤.4 says p1− p≤.4 .6=.24
so now
2
   
2
z
2.575
n≥.24  / 2 =.24
=1299.061 or n≥1300 .
E
.035
That is we have replaced the bound on p(1- p) of 1/4 = .25 by .24 above allowing a
somewhat smaller sample size of 1300 instead of 1354.
Note that by the symmetry of the function p(1- p) we would have found the same answer
if we'd said that the percentage to be estimated p = 1-(1- p) is at least 60% so that 1-p is
p≥.6 also says p 1− p≤.24 .
at most 40% :
Large sample hypothesis tests for one proportion are based
X −np0
Z =
=
 np 0 1− p 0 
upon the statistic
 X /n− p 0
 p0 1− p0 /  n
WEEK 11
page 7
which under the null hypothesis is approximately standard normal for large n by the
Central Limit Theorem (normal approximation to the binomial random variable X) .
We test the null hypothesis H 0 : p= p 0 against the various alternatives according to :
alternative hypothesis
p p0
p p0
p≠ p0
reject null hypothesis if
Z −z 
Z z 
Z −z  /2 or Z  z  /2
Continuity correction : If one is fussy it is possible to add a continuity correction
where we add plus 1/2 to X in the numerator of the expression for Z in the case of a test
value of Z to the left (as in Z −z / 2 or Z −z  depending on whether the test is twosided or one-sided) and add minus 1/2 to X for a value of Z to the right but this makes
little difference for large n and so is usually omitted.
Hypotheses concerning several proportions :
When testing whether two or more binomial populations have the same parameter p
when the actual parameters are p1 , p 2 ,... , p k we test the null hypothesis
H o : p1= p 2=...= p k = p
against the alternative that these parameters are not all equal. We reject H 0 when the
2
2
chi-squared random variable defined below satisfies   . For large samples we have
Zi=
X i −ni pi
 ni p i 1− pi 
is approximately standard normal and one can show that the sum of the squares of k
independent such variables :
 X i−n i pi 2
 =∑
i =1 n i pi 1− p i 
2
k
will be approximately chi-squared with k degrees of freedom. Under the null hypothesis
the p i 's are all equal to the parameter p so we replace them with the pooled estimate
x  x ... x k
x
p = 1 2
=
where x= x 1 x 2... x k and n=n1n 2...n k .
n1n 2...n k
n
The expected number of success and failures for the j th sample are estimated by
e 1j=n j p =n j  x /n and e 2j=n j 1− p =n j 1− x/ n
while the observed number of success and failures are o 1j= x j and o2j =n j − x j .
Then one checks that o1j −e 1j 2= x j−n j x /n2=o 2j−e 2j 2= n j− x j−n j 1− x / n2 so that
k
oij −eij 2 k
 x j−n j p 2
1
1
2 1
 =∑ ∑
=∑  x j −n j p 

= ∑
.
e ij
n j p 1− p 
p 1− p 
i =1 j =1
j=1
j=1 n j 
Under the null hypothesis that the p i 's are all equal to the parameter p this is same as
the chi-squared statistic above except that we have replaced p by its estimate p = x /n
2
2
k


which causes a loss of 1 degree of freedom ( so having k-1 degrees of freedom now ).
Z test for difference between two proportions : For large samples WEEK 11 page 8
when only two proportions are being compared if the null hypothesis is that there is no
difference between the two proportions we can alternately employ the statistic
Z =
X1 X2
−
n1 n2

p 1− p 

1 1

n1 n2

with p=
X 1X 2
n 1n 2
utilizing the pooled proportion to estimate the variance. Of course if we believe there is
a difference p 1− p 2 between the two proportions, by using the sample proportions to
estimate the actual ones in the expression for the variance in the denominator , we have
Z =
X1 X 2
− − p1− p 2
n1 n2

p 1 1− p 1  p 2 1− p 2

n1
n2
with p 1=
X1
X
and p 2= 2 .
n1
n2
This is used in the book to get a confidence interval for the difference p 1− p 2 .
EXAMPLE 4 problem 9.21 of text (like HW 9.19)
An ambulance service claims that at least 40% of its calls are life threatening
emergencies. If 49 of 150 were life threatening, can the null hypothesis H o : p≥.40 be
rejected in favor of the one-sided alternative that p < .4 at significance level .01 ?
We take the borderline null value p = .4 since any larger null value will lead to less
likely behavior. Our test statistic is
49−150 .40
X −np
11
=
=−
.
6
 np1− p
 150.40.60
Since this is larger than -2 but −z =−z .01=−2.327 is smaller, we can not reject the null
Z=
hypothesis at significance level .01. Note that a much larger value of p than .4 would
have lead to rejection (so we can reject significantly larger values of p ) but the null
hypothesis as stated here allows for p = .4 as a possibility.
EXAMPLE 5 problem 9.27 of text (like HW 9.29)
Tests are made on the proportion of defective castings produced by 5 different molds. If
there were 14 defectives among 100 castings made with Mold I, 33 defectives among
200 made with Mold II, 21 defectives among 180 made with Mold III, 17 defectives
among 120 made with Mold IV and 25 defectives among 150 made with Mold V, use the
.01 level of significance to test whether the true proportion of defectives is the same for
each mold.
Mold
I
II
III
IV
V | totals
---------------------------------------------------------------------------------number of defectives :
14 33
21
17
25 | 110
number of non-defectives 86 167 159 103 125 | 640
---------------------------------------------------------------------------------sample sizes
100 200 180 120 150 | 750
problem 9.27 continued ... Under the null hypothesis that the true WEEK 11 page 9
proportion is the same for each mold, our pooled estimate for the true proportion p is
p =
x 1x 2 x 3x 4 x 5
1433211725
110
11
=
=
=
n1n 2n 3n 4n 5 100200180120150
750
75
The observed number of defectives and non-defectives are o 1i= x i and o 2i=n i −x i
as given in the above table. The expected number of defectives for the ith mold are
n i p which we estimate with
n i p=ni
11
and similarly for the expected number of
75
non-defectives n i 1− p=ni −n i p obtaining the estimated expected values :
100(11/75) = 14 2/3 = 44/3, 200(11/75) = 88/3= 29 1/3, 180(11/75) = 26.4, 120(11/75)
= 17.6, 150(11/75) = 22 , 100 – 44/3 = 85 1/3 , 200-88/3= 170 2/3 , 180 – 26.4 =
153.6, 120 – 17.6 = 102.4, 150 – 22 = 128 Our chi-squared statistic is then
oij −eij 2
14−14 2/32 33−29 1/32 21−26.42 17−17.62 25−222
 =∑ ∑
=




e ij
44 /3
88/3
26.4
17.6
22
i =1 j =1
2
2
2
2
2
86−85 1/3 167−170 2/3 159−153.6 103−102.4 125−128





85 1/3
170 2/3
153.6
102.4
128
2
2
5
which after simplifying fractions becomes
1 11 243
9
9
1
121
243
9
9
 

 




= 2.3703835 .
33 24 220 440 22 192 1536 1280 2560 128
Since there are k = 5 samples and for a chi-squared random variable with k – 1 = 4
degrees of freedom we have 2.01=13.277 . At significance level .01we can not reject
the null hypothesis (since 2.37 is smaller than the chi-squared critical value 13.277 ) .
EXAMPLE 6 modified version of problem 9.28 (like HW 9.30 and 9.31)
A study showed that 64 out of 180 persons who saw a photocopying machine advertised
during a telecast of a baseball game and 75 of 180 other persons who saw it advertised
on a variety show remembered the brand name 2 hours later.
a) use the chi-squared statistic at significance level .05 to test whether the difference in
sample proportions is significant. ( H 0 : p1 = p 2 = p )
observed numbers :
baseball game
remembered
64
2 hours later
variety show |
totals
75
|
139
|
|
didn't remember
116
105
|
221
-------------------------------------------------------------------------------n 1 = 180
n 2 = 180
sample sizes
n = 360
pooled estimate
p =
x
6475
139
=
=
,
n
180180
360
1− p=
221
360
estimated expected numbers :
WEEK 11 page 10
remembered 180(139/360)= 69.5
69.5
didn't remember 180-69.5 = 110.5
110.5
The observed number of successes are o11 = x 1 =64 and o12 = x 2 =75
o 21=n1−x 1=116 and o 22=n2− x 2=105
The observed number of failures are
est. expected number of successes are e 11 =n1 p =69.5 and e12 =n2 p =69.5
est. expected # of failures e 21 =n 11− p =n1−e 11=110.5 and e 22 =n2 1− p =n2−e 12 =110.5
so we get
2
2
2
oij −eij 
64−69.52 75−69.52 116−110.52 105−110.52
=



e ij
69.5
69.5
110.5
110.5
j =1
2 = ∑ ∑
i =1
5.525.52 5.5 25.5 2
=

= 1.4180  2.05=3.841
69.5
110.5
is a chi-square value with 1 degree of freedom since for k = 2 samples, there is one
fewer or k – 1 = 1 degree of freedom when using p = x / n to estimate p .
Decision : Since the observed chi-squared value 1.4180 is less than the chi-squared
critical value 3.841 at significance level .05 with 1 degree of freedom,
we do not reject the null hypothesis that the proportions of people who remember are
equal for those who watched the telecast ballgame and those who watched the variety
show (hence the proportions of those who don't remember are also equal).
b) Use the Z statistic (on p 304 of the text) for comparing two proportions :
Under the null hypothesis that the proportions of those who remembered (successes)
are equal (hence the proportion of failures are equal) we can use the approximately
standard normal statistic
Z =
X1 X2
−
n1 n2


=

64
75
−
180 180
=
264−75
 
=
−22
= −1.1908
18.474908
139 221
139 221 1
1

90
360 360 180 180
X 1 X 2
139
with our pooled estimate of the proportion p = n n = 360 as before.
1
2
p 1− p 
1 1

n1 n2

At significance level .05 the observed z-value -1.1908 lies to the right of the z-critical
value −z .025=−1.96 so we do not reject the null hypothesis.
c) Verify that the square of the Z value found in part b) gives the chi-squared value
found in part a) :
Z 2=−1.1908043122=1.4180149 is the chi-squared value found in part a)
Note that an extreme Z value, either large negative or large positive, yields only a large
chi-squared value, so the chi-squared test is one sided whereas the Z test is two sided.
Analysis of r ×c tables . In such a table data are arranged in a two WEEK 11 page 11
way classification having r rows and c columns. Such data typicallyarises in two
fashions :
First we might again have samples from several populations (a given column
summarizes data from a given population) where now we allow the possibility that there
are more than two outcomes (r greater than 2) or in other words that the random
variables giving the observed numbers of outcomes for a given population have a
multinomial distribution. The case r = 2 is just the binomial situation we discussed in
the last section.
The other situation giving rise to an r ×c table is one in which we sample from a single
population but classify an item with respect to two categories (dimensions). We might
for example classify employees by how hard they work (very hard working, moderately
hard, moderately little, very little) and how much they earn (high income, medium
income, low income) which would give rise to a 4 by 3 contingency table. The entries
in the table would represent the numbers of employees observed for each of the 12
possible classifications.
In the first case the column totals (the sample sizes) are fixed, while in the second case
only the grand total for the entire table is fixed. For the first case the null hypothesis is
that for each of the r possible types the proportion of observations (probability) of that
type is the same for all k populations and thus takes the form
H 0 : pi1= pi2=...= p ik = pi
for i =1,2,... , r where
r
r
i=1
i=1
∑ pij =∑ pi =1
while in the second case we want to test the null hypothesis that the the random
variables with joint probability represented by the two way classification are
independent so that
H 0 : pij = pi , j = p1 i p 2  j  for i=1,2,. .. , r ; j=1,2,. .. , k
says for each entry in the table the ij entry is the product of the (marginal) row sum
times the (marginal) column sum for row i and column j . The alternative hypothesis
says that the two random variables are dependent.
In both cases the analysis is the same. We calculate the (estimated) expected cell
frequencies :
i th row total × j th column total 
ei j =
grand total
and substitute theses into the chi-squared with (r-1)(c-1) degrees of freedom :
oij −eij 2
 =∑ ∑
e ij
i =1 j =1
2
2
  with (r-1)(c-1) degrees of freedom.
2
We reject the null hypothesis if
r
c
The theory behind this involves a multidimensional version of
WEEK 11 page 12
the central limit theorem.
EXAMPLE 7 problem 9.39 (like HW 9.40)
The results of polls conducted 2 weeks and 4 weeks before a gubernatorial election are
shown in the following table :
2 weeks before
For Republican candidate
79
For Democratic candidate
84
Undecided
37
4 weeks before
91
66
43
Use the .05 level of significance to test whether there has been a change in opinion
during the two weeks between the two polls.
Under the null hypothesis that there has been no change, our pooled estimates for the
probabilities of choosing Republican, Democrat, or undecided are
(79+91)/400 = 17/40 , (84+66)/400 = 15/40= 3/8 , (37+43)/400 = 8/40 = 1/5
Our estimates of the expected number out of 200 people in each random sample of the
(before and after) population are 200(17/40) = 85, 200(15/40) = 75, 200(8/40) = 40 .
Note these agree with the above formula : (row sum)(column sum) / grand total
(Here both columns have the same column sum 200. )
Thus our chi-squared statistic with (r-1)(c-1) = 2 degrees of freedom has value
 79−852 91−852 84−752 66−752 37−402 43−402





85
85
75
75
40
40
72 162 18
= 
 =3.45706
85 75 40
2
2
 .05=5.991 with 2 degrees of freedom so we do not reject the null hypothesis.
2
=
Here
There is not enough evidence to conclude voter preferences have changed significantly.
Goodness of fit is the expression used in comparing an observed frequency distribution
with the values expected from a theoretical distribution. The test statistic is similar to the
chi-squared we have been using for multinomial data except there is only one population
we are using rather than several. The chi squared statistic is calculated from the
differences between observed and expected frequencies with k – m degrees of freedom
where m is the number of quantities needed to compute the expected frequencies :
oi−e i2
 =∑
.
ei
i =1
2
k
Johnson gives an example of testing whether 400 observations (the number of radio
messages received by an air traffic controller during 400 five minute intervals in which
the number of messages received ranged from 0 to 13 ) are coming from a Poisson
distribution. Note some of the frequencies are combined so that none of the
corresponding expected frequencies is smaller than 5. This is completely analogous to
the requirement that np≥15 and n1− p≥15 in the normal
WEEK 11 page 13
approximation to the binomial although this condition has been relaxed somewhat.
Indeed, assuming the number of messages received in separate 5 minute intervals are
independent identically distributed, in any of the 5 minute intervals either 7 messages
were incoming with some actual probability p or there were not 7 incoming with
probability 1-p so that restricting our attention to a particular number of messages
incoming (say 7), we see that the number of 5 minute intervals having this number 7 of
incoming messages is a binomial random variable which for large n = 400 we know is
approximately normal. Under the Poisson assumption with mean 4.6 being tested, the
14 counts out of 400 trials associated with various values of k between 0 and 13 are
indeed well approximated by a multinomial distribution having as parameters the
k
various Poisson probabilities
−
 e
k!
with =4.6 associated with these 14 values of k .
Of course this would not be completely accurate since the controller could have
observed 14 or more incoming messages during some 5 minute interval (albeit with very
small probability) . These rare events would not change things appreciably.
Note that in order to get all the expected frequencies above 5, Johnson has grouped some
of these together (0 or 1 messages received get lumped into a single class with their
frequencies combined and similarly the occurrence of 10, 11, 12 or 13 messages
received is lumped into a single class to which we are really adding 14 through infinity
as well with almost no noticeable difference ) . Only the one total frequency 400
(m = 1) is needed to compute the expected frequencies n p i which are the (sometimes
lumped) Poisson probabilities multiplied by n = 400. Thus instead of 14 classes, we
have k = 10 classes and thus k-m = 9 degrees of freedom obtained by using the lumped
frequencies.