-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats-confid.xml
211 lines (169 loc) · 11.3 KB
/
stats-confid.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?xml version="1.0" encoding="UTF-8" ?>
<!--********************************************************************
Copyright 2015 Robert A. Beezer
This file is part of MathBook XML.
MathBook XML is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 or version 3 of the
License (at your option).
MathBook XML is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with MathBook XML. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************-->
<!-- This file is part of the book -->
<!-- -->
<!-- Inquiries into Probability and Statistics - Math S–304 -->
<!-- -->
<!-- Copyright (C) 2016 Thomas W. Judson -->
<chapter xml:id="stats-confid" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>Estimating with Confidence</title>
<introduction>
<p>The learning objectives for this chapter are:
<ul>
<li>To understand and be able estimate with confidence.</li>
<li>To understand and be able to find confidence intervals for a population mean.</li>
</ul></p>
</introduction>
<section xml:id="section-stats-confid-interval-mean">
<title>Confidence Intervals for Population Means</title>
<example xml:id="example-stats-confid-sharks">
<p>Anyone who has ever seen the move <em>Jaws</em> knows that great white sharks are really big and really hungry. They are at the top of the food chain<mdash />well almost, orcas (AKA killer whales) have been known to prey on great whites. Your friend Brian has seen Jaws 25 times as well as all of the sequels. He claims that the average length of a great white is 20 feet. As evidence, he tells you that a 37 ft shark was trapped in a herring weir in New Brunswick, Canada, in the 1930s. Table<nbsp /><xref ref="table-stats-confid-shark" /> gives the lengths in feet of 44 great whites. Two questions:
<ol>
<li>Is your friend Brian correct?</li>
<li>What is the average length of a great white?</li>
</ol></p>
</example>
<table xml:id="table-stats-confid-shark">
<tabular halign="center" top="medium">
<row>
<cell>18.7</cell><cell>16.4</cell><cell>13.2</cell><cell>19.2</cell>
</row>
<row>
<cell>12.3</cell><cell>16.7</cell><cell>15.8</cell><cell>16.2</cell>
</row>
<row>
<cell>18.6</cell><cell>17.8</cell><cell>14.3</cell><cell>22.8</cell>
</row>
<row>
<cell>16.4</cell><cell>16.2</cell><cell>16.6</cell><cell>16.8</cell>
</row>
<row>
<cell>15.7</cell><cell>12.6</cell><cell>9.4</cell><cell>13.6</cell>
</row>
<row>
<cell>18.3</cell><cell>17.8</cell><cell>18.2</cell><cell>13.2</cell>
</row>
<row>
<cell>14.6</cell><cell>13.8</cell><cell>13.2</cell><cell>15.7</cell>
</row>
<row>
<cell>15.8</cell><cell>12.2</cell><cell>13.6</cell><cell>19.7</cell>
</row>
<row>
<cell>14.9</cell><cell>15.2</cell><cell>15.3</cell><cell>18.7</cell>
</row>
<row>
<cell>17.6</cell><cell>14.7</cell><cell>16.1</cell><cell>13.2</cell>
</row>
<row bottom="medium">
<cell>12.1</cell><cell>12.4</cell><cell>13.5</cell><cell>16.8</cell>
</row>
</tabular>
<caption>Lengths of great white sharks (in feet)</caption>
</table>
<exercise>
<statement>
<p>Is there significant evidence that your friend Brain is correct? Or is he just going off the deep end as usual? Assume that the population standard deviation is known and is <m>\sigma = 2.55</m> feet.<fn>Actually, we do not know <m>\sigma</m>, and it would be better to use a <m>t</m>-test.</fn></p>
</statement>
<hint>
<p>What is the null hypothesis?</p>
</hint>
</exercise>
<p>We would like to use statistics to obrain a realistic estimate of the average length of a great white shark from our sample of 44 sharks. We will do this by calculating a confidence interval for the population mean.</p>
<p>A <term>confidence interval</term> for a parameter such as a mean or a population proportion has two parts.
<ul>
<li>An interval calculated from that data that has the form
<me>\text{estimate} \pm \text{margin of error}</me></li>
<li>A <term>confidence level</term> <m>C</m> that gives the probability that the interval will capture the value of the true parameter with repeated sampling.</li>
</ul></p>
<p>Suppose that we choose a simple random sample of size <m>n</m> from a population where we know the standard deviation <m>\sigma</m> and we wish to estimate the mean <m>\mu</m>. A level <m>C</m> confidence interval for <m>\mu</m> is
<me>\overline{x} \pm z^* \frac{\sigma}{\sqrt{n}}.</me>
The value of <m>z^*</m> is given in Table<nbsp /><xref ref="table-stats-confid-z-star" />.</p>
<table xml:id="table-stats-confid-z-star">
<tabular halign="center" top="medium">
<row bottom="medium">
<cell>Confidence Level</cell><cell>Tail Area</cell><cell><m>z^*</m></cell>
</row>
<row>
<cell>90<percent /></cell><cell>0.05</cell><cell>1.645</cell>
</row>
<row>
<cell>95<percent /></cell><cell>0.025</cell><cell>1.960</cell>
</row>
<row bottom="medium">
<cell>99<percent /></cell><cell>0.005</cell><cell>2.576</cell>
</row>
</tabular>
</table>
<example>
<p>Our goal is the calculate a 95<percent /> confidence interval for the average length of a great white shark from the data in Table<nbsp /><xref ref="table-stats-confid-shark" />. We will assume that the population standard deviation is known and is <m>\sigma = 2.55</m> feet.
<ul>
<li>Calculate the mean. <m>\overline{x} = 15.59</m>.</li>
<li>From Table<nbsp /><xref ref="table-stats-confid-z-star" /> determine <m>z^* = 1.960</m>.</li>
<li>A 95<percent /> confidence interval is given by
<me>\overline{x} \pm z^* \frac{\sigma}{\sqrt{n}} = 15.59 \pm 1.960 \frac{2.55}{\sqrt{44}} = 15.59 \pm 0.75.</me></li>
</ul></p>
</example>
<sage language="r">
<input>
<![CDATA[sharks <- c(18.7, 16.4, 13.2, 19.2, 12.3, 16.7, 15.8, 16.2, 18.6, 17.8, 14.3, 22.8, 16.4, 16.2, 16.6, 16.8, 15.7, 12.6, 9.4, 13.6, 18.3, 17.8, 18.2, 13.2, 14.6, 13.8, 13.2, 15.7, 15.8, 12.2, 13.6, 19.7, 14.9, 15.2, 15.3, 18.7, 17.6, 14.7, 16.1, 13.2, 12.1, 12.4, 13.5, 16.8)
xbar = mean(sharks) #sample mean
sigma = 2.55 # population standard deviation
n = length(sharks) # sample size
sem = sigma/sqrt(n) # standard error of the mean
E = qnorm(.975)*sem # margin of error, 95% confidence level implies 97.5% of the normal distribution in the upper tail
xbar + c(-E, E) # confidence interval]]>
</input>
</sage>
<exercise>
<statement>
<p>Table<nbsp /><xref ref="table-stats-hypoth-iq" /> the IQ test scores for 31 seventh-grade girls in a Midwest school district. If we treat the 31 students as a simple random sample of all seventh-grade girls in the district, what is a 90<percent /> confidence interval for the mean IQ score of all seventh-grade girls in the district? Assume that the population standard deviation is <m>\sigma = 15</m>.</p>
</statement>
</exercise>
</section>
<section xml:id="section-stats-confid-interval-prop">
<title>Confidence Intervals for Population Proportions</title>
<p>Confidence intervals for proportions work much the same way as confidence intervals for means except that we replace the standard deviation with the <term>standard error</term> of <m>\hat{p}</m>,
<me>\text{SE} = \sqrt{\frac{\hat{p}(1 - \hat{p})}{n}}</me>
Thus, our confidence interval is given by
<me>\text{estimate} \pm \text{margin of error} = \text{estimate} \pm z^*\text{SE}.</me></p>
<example>
<p>Bruce Long and Susan Jordan are candidates for a tightly fought race for a seat in Congress. You are planning a sample survey to find out how many voters plan to cast their ballot for Ms. Long. You will contact a simple random sample of likely voters in the 4th Congressional District. You want to estimate <m>p</m>, the proportion of voters who will cast their ballot for Ms. Long with a 95<percent /> confidence interval. In a sample of 500 voters, 270 said that they planned to vote for Ms. Long. Thus, our confidence interval is given by
<me>\hat{p} \pm z^* \sqrt{\frac{\hat{p}(1 - \hat{p})}{n}} = 0.54 \pm 1.960 \cdot 0.0223 = 0.54 \pm 0.0437.</me></p>
</example>
<paragraphs>
<title>Sample size for a desired margin of error</title>
<p>The level <m>C</m> confidence interval for a population proportion <m>p</m> will have a margin of error approximately equal to a specified value <m>m</m> when the sample size is
<me>n = \left( \frac{z^*}{m} \right)^2 p^*(1- p^*),</me>
where <m>p^*</m> is the guessed value for the sample proportion. The margin of error will be less than or equal to <m>m</m> if you guess <m>p^* = 0.5</m>.</p>
</paragraphs>
<exercise>
<statement>
<p>How many voters would need to be polled in order to have an error of no larger than 3<percent /> or 0.03?</p>
</statement>
<hint>
<p>Assume <m>p^* = 0.5</m>. Why can you make this assumption?</p>
</hint>
</exercise>
<p>Here is the R code for Example<nbsp /><xref ref="example-stats-confid-sharks" /> if we use a <m>t</m>-test.</p>
<sage language="r">
<input>
<![CDATA[sharks <- c(18.7, 16.4, 13.2, 19.2, 12.3, 16.7, 15.8, 16.2, 18.6, 17.8, 14.3, 22.8, 16.4, 16.2, 16.6, 16.8, 15.7, 12.6, 9.4, 13.6, 18.3, 17.8, 18.2, 13.2, 14.6, 13.8, 13.2, 15.7, 15.8, 12.2, 13.6, 19.7, 14.9, 15.2, 15.3, 18.7, 17.6, 14.7, 16.1, 13.2, 12.1, 12.4, 13.5, 16.8)
t.test(sharks, mu=20)]]>
</input>
</sage>
</section>
</chapter>