Confidence Intervals, Sample Size Calculation - Discussion 8 | STAT 310, Study notes of Mathematical Statistics

Material Type: Notes; Class: Introduction to Mathematical Statistics; Subject: STATISTICS; University: University of Wisconsin - Madison; Term: Spring 2008;

Typology: Study notes

Pre 2010

Uploaded on 09/02/2009

koofers-user-w3j
koofers-user-w3j 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
STAT 310 DISCUSSION 8
TA: Yi Chai
Office: 1335N MSC
Webpage: http://www.stat.wisc.edu/chaiyi
Office Hours: 11:00-12:00pm T and 1:00-2:00pm Th or by appointment
1. Confidence Intervals
100(1 α)%-C.I. Margin of error Length of C.I.
mean of N(µ, σ2)
known σ2¯
Y±zα/2×σ
nzα/2×σ
n2zα/2×σ
n
unknown σ2¯
Y±tα/2,n1×s
ntα/2,n1×s
n2tα/2,n1×s
n
Proportions ˆp±zα/2rˆp(1 ˆp)
nzα/2rˆp(1 ˆp)
n2zα/2rˆp(1 ˆp)
n
2. Sample size calculation:
Estimation of mean of a normal distribution N(µ, σ2) with known σ2.
The sample size nsuch that the margin of error for the 1 αconfidence interval for µis no
greater than a prescribed value δis
n>σ2(Zα/2
δ)2
Estimation of proportion. The required sample size is
n>1
4(Zα/2
δ)2
3. Examples
Example 1: (6.3.10 from the textbook.) How many times must we toss a coin to ensure that a
0.95 confidence interval, for the probability of heads on a single toss, has length less than 0.1,
0.05 and 0.01, respectively?
Example 2: (6.3.12 from the textbook.) Suppose that a measurement on a population can be
assumed to be distributed N(µ, 2) where µis unknown and that the size of the population is very
large. A researcher wants to determine a 0.95 confidence interval for µthat is no longer than 1.
What is the minimum sample size that will guarantee this?
Example 3: (6.3.15 from the textbook.) Generate 103samples of size n= 5 from the Bernoulli(0.5)
distribution. For each of these samples, calculate (6.3.6)
"¯xz(1+γ)/2r¯x(1 ¯x)
n,¯x+z(1+γ)/2r¯x(1 ¯x)
n#
with γ= 0.95 and record the proportion of intervals that contain the true value. What do you
notice? Repeat this simulation with n= 20. What do you notice?
1
pf2

Partial preview of the text

Download Confidence Intervals, Sample Size Calculation - Discussion 8 | STAT 310 and more Study notes Mathematical Statistics in PDF only on Docsity!

STAT 310 DISCUSSION 8

TA: Yi Chai Office: 1335N MSC Email: [email protected] Webpage: http://www.stat.wisc.edu/∼chaiyi Office Hours: 11:00-12:00pm T and 1:00-2:00pm Th or by appointment

  1. Confidence Intervals

100(1 − α)%-C.I. Margin of error Length of C.I.

mean of N (μ, σ^2 )

known σ^2 Y¯ ± zα/ 2 × σ √ n

zα/ 2 × σ √ n

2 zα/ 2 × σ √ n

unknown σ^2 Y¯ ± tα/ 2 ,n− 1 × s √ n

tα/ 2 ,n− 1 × s √ n

2 tα/ 2 ,n− 1 × s √ n

Proportions pˆ ± zα/ 2

pˆ(1 − pˆ) n zα/ 2

pˆ(1 − pˆ) n 2 zα/ 2

pˆ(1 − pˆ) n

  1. Sample size calculation:
    • Estimation of mean of a normal distribution N (μ, σ^2 ) with known σ^2. The sample size n such that the margin of error for the 1 − α confidence interval for μ is no greater than a prescribed value δ is n > σ^2 (

Zα/ 2 δ

)^2

  • Estimation of proportion. The required sample size is

n >

Zα/ 2 δ

)^2

  1. Examples
    • Example 1: (6.3.10 from the textbook.) How many times must we toss a coin to ensure that a 0.95 confidence interval, for the probability of heads on a single toss, has length less than 0.1, 0.05 and 0.01, respectively?
    • Example 2: (6.3.12 from the textbook.) Suppose that a measurement on a population can be assumed to be distributed N (μ, 2) where μ is unknown and that the size of the population is very large. A researcher wants to determine a 0.95 confidence interval for μ that is no longer than 1. What is the minimum sample size that will guarantee this?
    • Example 3: (6.3.15 from the textbook.) Generate 10^3 samples of size n = 5 from the Bernoulli(0.5) distribution. For each of these samples, calculate (6.3.6) [ x ¯ − z(1+γ)/ 2

x¯(1 − x¯) n , x¯ + z(1+γ)/ 2

x¯(1 − x¯) n

]

with γ = 0.95 and record the proportion of intervals that contain the true value. What do you notice? Repeat this simulation with n = 20. What do you notice?

S: number of simulation

n: sample size

simu <- function(S,n,p) { num= for (simno in 1:S) { x=rbinom(n,1,p) hatp=sum(x)/n lower=hatp-1.96sqrt(hatp(1-hatp)/n) upper=hatp+1.96sqrt(hatp(1-hatp)/n) if (lower<=p & upper>=p) { num=num+1 } } return(num) }

simu(1000,5,0.5) simu(1000,20,0.5)

  • Example 4: (6.3.16 from the textbook.) Generate 10^4 samples of size n = 5 from the N (0, 1) distribution. For each of these samples, calculate the interval

(¯x − s/

5 , x¯ + s/

where s is the sample standard deviation, and record the proportion of times this interval contains μ = 0. Repeat this simulation with n =10 and 100. Compare your results.

simu <- function(S,n) { num= for (simno in 1:S) { x=rnorm(n) lower=mean(x)-sd(x)/sqrt(n) upper=mean(x)+sd(x)/sqrt(n) if (lower<0 & upper>0) { num=num+1 } } return(num) }

simu(10000,5) simu(10000,10) simu(10000,20)