程序代写代做代考 Statistical Inference STAT 431

Statistical Inference STAT 431
Lecture 6: Inferences for Single Samples (I)

• Setup: X1,…Xn
Var(Xi) = 2 X=n Xi
i.i.d.
⇠ F with E(Xi) = μ
• An intuitive estimator for μ is the sample mean ̄ 1 Xn
i=1
Sample Mean
• Using the mean and the variance of F , we have E(X ̄)=μ, Var(X ̄)=2
n
– So X ̄ is an unbiased estimator for μ, with the variance shown above.
• A further question: What is the sampling distribution of X ̄ ?
STAT 431 2

Sample Mean: Exact Sampling Distributions
• From probability theory, we know the exact sampling distribution of the sample
mean in the following two cases
1. Bernoulli population: X1 , . . . , Xn i.i.d. Bernoulli(p)
⇣ ̄x⌘ Xn !✓n◆x nx P X=n =P Xi=x = x p(1p)
i=1
2. Normal population: X1, . . . , Xn i.i.d. N(μ, 2) X ̄ ⇠ N ✓ μ , 2 ◆
n
, x=0,1,…,n.
STAT 431
3

Sample Mean: Approximate Sampling Distributions • Central Limit Theorem:
LetX1,…,Xn bearandomsampledrawnfromanarbitrary 2
distribution with meanμ and variance . As n ! 1, X ̄ μ
/pn )N(0,1) • Intuitively: For large n, d ✓ 2 ◆
X ̄ ⇡ N μ , n
• A practical question: How large an n do we need to apply the approximation?
– The shape of the distribution: skewness
– The desired accuracy
STAT 431 4

Skewness and Normal Approximation
population density
sample size = 2
0.0
0.2 0.4
0.6
0.8
1.0
0.0 0.2
0.4 0.6 0.8
x.bar
sample size = 25
1.0
x
sample size = 5
0.2
0.4
0.6
0.8
0.3 0.4
0.5 0.6
x.bar
0.7
x.bar
STAT 431
5
0.0 0.5 1.0 1.5 2.0
2.5 3.0
3.5
0.6
0.8
0 2 4
6
0.0 0.5 1.0 1.5 2.0
Density
Density
1.0 1.2 1.4
Density
Density

Skewness and Normal Approximation
population density
sample size = 2

● ●●●●●● ●
● ●● ●
● ●●●
0.0 0.2 0.4 0.6 0.8 1.0 x
sample size = 5
−3 −2 −1 0 1 2 3 Theoretical Quantiles
sample size = 25

● ●
● ●●●
● ●● ●

● ●
● ●
●●●● ●
● ●
●● ●●●●
● ●

● ●
● ●●●●●● ●
−3 −2 −1 0 1 2 3 Theoretical Quantiles
−3 −2 −1 0 1 2 3 Theoretical Quantiles
STAT 431
6
Sample Quantiles
−3 −2 −1 0 1 2 3 0.6
0.8
Density
1.0 1.2 1.4
Sample Quantiles
−3 −2 −1 0 1 2 3 4
−2
Sample Quantiles
−1 0 1 2

Skewness and Normal Approximation (Cont’d)
population density
sample size = 2
0.0 0.2 0.4
0.6 0.8
1.0
0.1 0.2 0.3 0.4
x.bar
sample size = 25
x
sample size = 5
0.05 0.10 0.15 0.20 0.25 0.30 0.35
x.bar
0.10 0.12 0.14 0.16 0.18 0.20 0.22 0.24
x.bar
STAT 431
7
Density
Density
0 1 2 3 4
0 2 4 6 8 10
Density
Density
05101520 0123456

Skewness and Normal Approximation (Cont’d)
population density
sample size = 2
● ●
● ●
● ● ●●●●●●
● ● ●
● ●●●



0.0 0.2 0.4 0.6 0.8 1.0 x
sample size = 5
−3 −2 −1 0 1 2 3 Theoretical Quantiles
sample size = 25


●● ●●●
●● ●
● ●

● ● ●
●● ●



● ●●
●●



●●● ●
● ●
● ●●
−3 −2 −1 0 1 2 3 Theoretical Quantiles
−3 −2 −1 0 1 2 3 Theoretical Quantiles
STAT 431
8
Sample Quantiles
−2 −1 0 1 2 3 4
0 1
Density
2 3 4
Sample Quantiles
−3 −2 −1 0 1 2 3
Sample Quantiles
−2 −1 0 1 2 3 4

A Special Case: Bernoulli Population
• If X1,…Xn i.i.d.Bernoulli(p), thennX ̄ ⇠ Bin(n,p)
• Ruleofthumb:ifboth np10 andn(1p)10,then X ̄ p n X ̄ n p d
pp(1p)/n = pnp(1p) ⇡ N (0, 1)
• Continuity correction Example:n=20,p=0.5
– Exact probability: P (nX ̄  8) = – Without continuity correction
̄
P
✓nX ̄p 810 ◆ P (nX  8) ⇡ P pnp(1p)  p20(0.5)(0.5)
8 20 i=0 i
(0.5)i (0.5)20i = 0.2517 ⇡ (0.8944) = 0.1867
⇡ (0.6708) = 0.2514

With continuity correction
✓ nX ̄p 810+0.5 ◆ P (nX  8) ⇡ P pnp(1p)  p20(0.5)(0.5)
̄
STAT 431
9

Large Sample Inferences for Mean i.i.d.
X1,…,Xn ⇠ F
• F is not necessarily normal!
• Parameter of interest: the mean value μ of F
• We shall deal with the large sample case:
– The sample size n is large. Typically, n 30.
– The population SD could be assumed known.
If not, then the sample SD S gives accurate estimation. [can think of as S = ]
• Point estimation of μ : we always use X ̄ .
• Interest: confidence interval and hypothesis testing
• Under our setup, the following pivotal r.v. for μ plays the key role
X ̄ μ d
/pn ⇡N(0,1)
STAT 431 10

• •
Example: Chips Ahoy!
In the mid-1990’s, Nabisco advertised Chips Ahoy! as being “1000 chips delicious”
In late 1990’s, a group of students at the US Air Force Academy conducted a study on the number of chips contained in each
18 oz bag by sampling 42 bags from 275 sent by the company
STAT 431 11

Data: counts of chips per bag in 42 sampled bags
• •
• •
Interested in constructing a 95% confidence interval for the average number of chips μ per bag
By pivotality of Z ,
✓ X ̄μ ◆
Histogram of chipcount
Example: Chips Ahoy! (Cont’d)
Pμ 1.96Z = /pn 1.96 ⇡0.95 So, a 95% confidence interval for μ is
 ̄ ̄ X 1.96pn, X + 1.96pn
1000
1100 1200 1300 1400 1500 1600
chipcount
n = 42
x ̄ = 1261.57, ⇡ s = 117.58 .
So, we obtain the CI
[1226.01, 1297.13]
Sample mean & sample SD
x ̄ = 1261.57 s = 117.58
STAT 431
12
For this data,
and
Frequency
0 5 10 15

Confidence Interval with Pre-specified Width
• We want the confidence interval [for a given confidence level] to be narrow
• Sometimes, we might want it to be no wider than a pre-specified width

• Fix the confidence level at 95%, the half-width of the CI is 1.96 pn
1.96 is determined by the confidence level
is a population parameterèIts value cannot be changed
– – –
does n needtobe? p p
We could only increase the sample size to reach the pre-specified width
• Chip Ahoy! Example: If we want the 95% CI to be no wider than 25 , how large
– Notethat⇡s=117.58èwidth=2⇥1.96/ n=460.91/ n
– Solve 460.91/pn  25 è n 339.9
– Therefore, we need a sample of size at least 340 to produce a 95% confidence interval no wider than 25
– Note: sample size has to be an integer!
STAT 431 13

General Two-Sided Confidence Intervals for the Mean
at any confidence level
• We can construct CI for the mean  ̄ ̄
100(1 ↵)%
X z↵/2pn, X +z↵/2pn
μ
• ThewidthofthisCIis 2⇥z/2pn
• IfwewanttheCItobenowiderthana
pre-specified width 2E , solving
E  z↵/2/pn l⇣z↵/2⌘2m
èwe need a sample size n E
• The half-width E is also called margin of error of the CI
STAT 431
14

Example: Chips Ahoy! (Cont’d)
• Nabisco advertised Chips Ahoy! as being “1000 chip delicious”
• To guarantee that, the average number of chips per bag needs to be at least 1200
• Suppose you work for Nabisco, and would like to prove the above claim.
How should you set up the null and the alternative hypotheses? 1. H0 :μ1200, vs. H1 :μ>1200
2.
3. H0 :μ=1200, vs. H1 :μ6=1200
H0 :μ1200, vs. H1 :μ<1200 • What if you work for a competing company of Nabisco? STAT 431 15 Example: Chips Ahoy! (Cont’d) • Suppose we have decided to test H0 :μ1200, vs. H1 :μ>1200
X ̄ 1200
• To perform the test, we use the test statistic Z = /pn
1261.57 1200
– With the current sample, the observed value is z = 117.58/p42
• The next step is to compute the P-value. Here, ✓ X ̄ 1200 P-value= maxPμ(Zz)= max Pμ p

z
μ1200 μ1200 / n
✓ X ̄ μ 1200 μ ◆ =maxPμ pz+p
μ1200 / n / n
✓ 1200μ◆ = max 1 z+ p
μ1200 / n = 1 (3.39) = 0.0003
So, H0 is rejected at significance level = 0.05
STAT 431 16

General Lower One-Sided Test • Consider the general form of the problem
H0 :μμ0 vs. H1 :μ>μ0 X ̄ μ 0 x ̄ μ 0
• Test statistic Z = /pn (observed value z = /pn )
✓ X ̄ μ 0 p

z
• Computing P-value
P-value = maxPμ(Z z) = max Pμ
/ n
μμ0 =maxPμ
μμ0
=max1 z+ p
μμ0
✓ X ̄ μ μ 0 μ ◆ p z+ p
/ n / n ✓ μ0 μ◆
• Decision: for a test with significance level ↵ RejectH0 when P-value=1(z)< z>z↵
x ̄>μ0 +z↵pn
μμ0 / n = 1 (z)
STAT 431
17

Power of the Test • For a test, we could consider the function
⇡(μ) = Pμ(Test rejects H0) – A function of the mean μ
– When H0 is true, ⇡(μ) equals the probability of type I error
– When H1 is true, it equals 1 – probability of type II error, i.e., the probability of
rejecting H0 correctly, i.e., power
• FortestingH0 :μμ0,vs.H1 :μ>μ0 ,ourtesthaspower
✓ ̄ ◆ ⇡(μ)=Pμ X>μ0+z↵pn
μ0 μ = 1 (z↵ + /pn )
μμ0 = (z↵ + /pn )
STAT 431 18

Power Function of the Test for Chips Ahoy! ( ↵=0.05)
Power function: Chips Ahoy! example

• •
The function value varies between 0 and 1, and is less than the significance level = 0.05 when μ follows the null hypothesis
It is monotone increasing as μ increases
If we increase the sample size, the function increases faster with μ . So the power is larger at the same value of μ for larger n under the alternative hypothesis.
n = 100
= 0.05
n = 42
1200 1250
average number of chips per bag
1300 1350
STAT 431
19
power
0.0 0.2 0.4 0.6 0.8 1.0

Test with Guaranteed Power
• Sometimes, it is of interest to determine the minimum sample size n , such that
when the true mean μ is greater than μ0 by a certain threshold, say, when μ μ0 ,
a test with significance level ↵ will reject the null with probability at least 1 , i.e.,thepowerofthetestat μ=μ0 + isatleast1 .
• To find this minimum sample size, we solve
✓ μ μ0 ◆ ⇥
⇤(μ)=⇤(μ0+⇥)= z↵+ ⌅/pn =(z↵+⌅/pn)=1
Since (z) = 1 , we obtain
z↵ + ⇥/pn = z
Solving for n, we get

nl⇣(z↵ +z)⌘2m
STAT 431
20

General Two-Sided Test • Thehypotheses: H0 :μ=μ0,vs.H1 :μ6=μ0
X ̄ μ x ̄ μ 0
• Test statistic: Z = p 0 (observed value z = /pn )
• P-value:
• Decision [with significance level ↵]
/ n
P -value = Pμ0 (|Z| |z|) = 21 (|z|) Reject H0 when

|z|>z↵/2
|x ̄μ0|>z↵/2pn
P-value=2 1(|z|) <↵ STAT 431 21 General Two-Sided Test (Cont’d) • Power function ✓ μ0 μ ◆ (p.244 of Textbook) (μ) = z/2 + ⇥/pn + ✓ μ μ0 ◆ z/2 + ⇥/pn STAT 431 22 • Key points of this class: Class Summary – Sampling distributions of the sample mean • Exact distribution / normal approximation / continuity correction – Pivotal random variable for large sample inferences for mean – Two-sided confidence interval for mean • Sample size determination for pre-specified width – One-sided hypothesis testing for mean • Test / power function / sample size determination for pre-specified power – Two-sided hypothesis testing for mean • Test / power function • Reading: Sections 5.1 and 7.1 • Next class: Inferences for single samples (II) (Sec. 5.2, 5.3 &7.2) STAT 431 23