0% found this document useful (0 votes)
11 views82 pages

Module03 Slides Print

This document outlines the concepts of interval estimation and confidence intervals in statistics, focusing on how to quantify uncertainty in estimates. It explains the standard error, the importance of confidence intervals, and provides examples of how to calculate and interpret these intervals. Additionally, it discusses relevant probability distributions and the factors affecting the width of confidence intervals.

Uploaded by

bhaikuddus197
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views82 pages

Module03 Slides Print

This document outlines the concepts of interval estimation and confidence intervals in statistics, focusing on how to quantify uncertainty in estimates. It explains the standard error, the importance of confidence intervals, and provides examples of how to calculate and interpret these intervals. Additionally, it discusses relevant probability distributions and the factors affecting the width of confidence intervals.

Uploaded by

bhaikuddus197
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Interval estimation: Part 1

(Module 3)

Statistics (MAST20005) &


Elements of Statistics
(MAST90058)

School of Mathematics and Statistics


University of Melbourne

Semester 2, 2022
Aims of this module

• Introduce the idea of quantifying uncertainty and describe some


methods for doing so
• Explain interval estimation, particularly confidence intervals,
which are the most common type of interval estimate
• Describe some important probability distribution that appear in
many statistical procedures
• Work through some common, simple inference scenarios

2 of 82
Outline

The need to quantify uncertainty

Standard error

Confidence intervals
Introduction
Definition
Important distributions
Pivots
Common scenarios

3 of 82
Statistics: the big picture

4 of 82
How useful are point estimates?
Example: surveying Melbourne residents as part of a disability study.
The results will be used to set a budget for disability support.

Estimate from survey: 5% of residents are disabled


What can we conclude?

Estimate from a second survey: 2% of residents are disabled


What can we now conclude?

What other information would be useful to know?

5 of 82
Going beyond point estimates

• Point estimates are usually only a starting point


• Insufficient to conclusively answer real questions of interest
• Perpetual lurking questions:
◦ How confident are you in the estimate?
◦ How accurate is it?
• We need ways to quantify and communicate the uncertainty in
our estimates.

6 of 82
Outline

The need to quantify uncertainty

Standard error

Confidence intervals
Introduction
Definition
Important distributions
Pivots
Common scenarios

7 of 82
Report sd(Θ̂)?
Previously, we calculated the variance of our estimators.
q
Reminder: sd(Θ̂) = var(Θ̂)

This tells us a typical amount by which the estimate will vary from
one sample to another, and thus (for an unbiased estimator) how
close to the true parameter value it is likely to be.

Can we just report that? (Alongside our estimate, θ̂)

Problem: this is usually an expression that depends on the parameter


values, which we don’t know and are trying to estimate.

8 of 82
Estimate sd(Θ̂)!
We know how to deal with parameter values. . . we estimate them!

Let’s estimate the standard deviation of our estimator.

A common approach: substitute point estimates into the expression


for the variance.

Example:
Consider the sample proportion, p̂ = X/n.
We know that var(p̂) = p(1−p)
n .
Therefore, an estimate is var(p̂)
c = p̂(1−p̂)
n .

9 of 82
If we take a sample of size n = 100 and observe x = 30, we get

p̂ = 30/100 = 0.3,
r r
p̂(1 − p̂) 0.3 × 0.7
sd(p̂) =
b = = 0.046.
n 100

We refer to this estimate as the standard error and write:

se(p̂) = 0.046

10 of 82
Standard error
The standard error of an estimate is the estimated standard deviation
of the estimator.

Notation:
• Parameter: θ
• Estimator: Θ̂
• Estimate: θ̂
• Standard deviation of the estimator: sd(Θ̂)
• Standard error of the estimate: se(θ̂)

Note: some people also refer to the standard deviation of the


estimator as the standard error. This is potentially confusing, best to
avoid doing this.
11 of 82
Reporting the standard error
There are many ways that people do this.

Suppose that p̂ = 0.3 and se(p̂) = 0.046.

Here are some examples:


• 0.3 (0.046)
• 0.3 ± 0.046
• 0.3 ± 0.092 [= 2 × se(p̂)]
This now gives us some useful information about the (estimated)
accuracy of our estimate.

12 of 82
Back to the disability example
More info:
• First survey: 5% ± 4%
• Second survey: 2% ± 0.1%

What would we now conclude?

What result should we use for setting the disability support budget?

13 of 82
Outline

The need to quantify uncertainty

Standard error

Confidence intervals
Introduction
Definition
Important distributions
Pivots
Common scenarios

14 of 82
Interval estimates
Let’s go one step further. . .
The form est ± error can be expressed as an interval,
(est − error, est + error).

This is an example of an interval estimate.

More general and more useful than just reporting a standard error.
For example, it can cope with skewed (asymmetric) sampling
distributions.

How can we calculate interval estimates?

15 of 82
Example
Random sample (iid): X1 , . . . , Xn ∼ N(µ, 1)

The sampling distribution of the sample mean is X̄ ∼ N(µ, n1 ).


Since we know that Φ−1 (0.025) = −1.96, we can write:
 
X̄ − µ
Pr −1.96 < √ < 1.96 = 1 − 2 × 0.025 = 0.95
σ/ n

or, equivalently,
 
1 1
Pr µ − 1.96 √ < X̄ < µ + 1.96 √ = 0.95
n n

16 of 82
0.4 shaded area is 0.95

0.3
Stan. Norm. PDF

0.2

0.1

0.0
−3 −2 −1 0 1 2 −3
x

17 of 82
Rearranging gives:
 
1 1
Pr X̄ − 1.96 √ < µ < X̄ + 1.96 √ = 0.95
n n

√ √
This says that the interval (X̄ − 1.96/ n, X̄ + 1.96/ n) has
probability 0.95 of containing the parameter µ.

We use this as an interval estimator.


√ √
The resulting interval estimate, (x̄ − 1.96/ n, x̄ + 1.96/ n) is called
a 95% confidence interval for µ.

18 of 82
Sampling distribution of the interval estimator

• Is this an estimator?
• Does it have a sampling distribution?
• What does it look like?
• There are two statistics here, the endpoints of the interval:

Pr(L < µ < U) = 0.95

• They will have a joint (bivariate) sampling distribution

19 of 82
Example
For the previous example:
• Realisations of the interval will have a fixed width but a random
location
• The randomness is due to X̄
• Sampling distribution:
 
1 1
L ∼ N µ − 1.96 √ ,
n n
 
1 1
U ∼ N µ + 1.96 √ ,
n n
1
U − L = 2 × 1.96 √
n

20 of 82
• Can write it more formally as a bivariate normal distribution:
" # !
µ − 1.96 √1n 1 1 1
  
L
∼ N2 ,
U µ + 1.96 √1n n 1 1

• Note that here we have perfect correlation, cor(L, U ) = 1


• Usually, easier and more useful to think about realisations of the
actual interval. . .

21 of 82
µ

22 of 82
Interpretation

• This interval estimator is a random interval and is calculable from


our sample. The parameter is fixed and unknown.
• Before the sample is taken, the probability the random interval
contains µ is 95%.
• After the sample is taken, we have a realised interval. It no longer
has a probabilistic interpretation; it either contains µ or it doesn’t.
• This makes the interpretation somewhat tricky. We argue simply
that it would be unlucky if our interval did not contain µ.
• In this example, the interval happens to be of the form, est ± error.
This will be the case for many of the confidence intervals we derive.

23 of 82
Example (more general)
Random sample (iid): X1 , . . . , Xn ∼ N(µ, σ 2 ), and assume that we
know the value of σ 2 .
2
The sampling distribution of the sample mean is X̄ ∼ N(µ, σn ).
Let Φ−1 (1 − α/2) = c, so we can write:
 
X̄ − µ
Pr −c < √ <c =1−α
σ/ n

or, equivalently,
 
σ σ
Pr µ − c √ < X̄ < µ + c √ =1−α
n n

24 of 82
Rearranging gives:
 
σ σ
Pr X̄ − c √ < µ < X̄ + c √ =1−α
n n

The following random interval contains µ with probability 1 − α:


 
σ σ
X̄ − c √ , X̄ + c √
n n

Observe x̄ and construct the interval. This gives a 100 · (1 − α)%


confidence interval for the population mean µ.

25 of 82
Worked example
Suppose X ∼ N(µ, 362 ) represents the lifetime of a light bulb, in
hours. Test 27 bulbs, observe x̄ = 1478.

Let c = Φ−1 (0.975). A 95% confidence interval for µ is:


   
σ 36
x̄ ± c √ = 1478 ± 1.96 √ = [1464, 1492]
n 27

In other words, we have good evidence that the mean lifetime for a
light bulb is approximately 1,460–1,490 hours.

26 of 82
Example (CLT approximation)

• If the distribution is not normal, we can use the Central Limit



Theorem if n is large enough, (X̄ − µ)/(σ/ n) ≈ N (0, 1)
• Example: X is the amount of orange juice consumed (g/day) by
an Australian. Know σ = 96. Sampled 576 Australians and found
x̄ = 133 g/day.
• An approximate 90% CI for the mean amount of orange juice
consumed by an Australian, regardless of the underlying
distribution for individual orange juice consumption, is:
 
96
133 ± 1.645 √ = [126, 140]
576
• In some studies, n is small because observations are expensive.

27 of 82
Shaded
Probability is 90%

-1.645 1.645

28 of 82
Definitions

• An interval estimate is a pair of statistics defining an interval that


aims to convey an estimate (of a parameter) with uncertainty.
• A confidence interval is an interval estimate constructed such that
the corresponding interval estimator has a specified probability,
known as the confidence level, of containing the true value of the
parameter being estimated.
• We often use the abbreviation CI for ‘confidence interval’.

29 of 82
General technique for deriving a CI
• Start with an estimator, T , whose sampling distribution is known
• Write the central probability interval based on its sampling
distribution,
Pr (π0.025 < T < π0.975 ) = 0.95
• The endpoints will depend on the parameter, θ, so can write it as,

Pr (a(θ) < T < b(θ)) = 0.95


• Invert it to get a random interval for the parameter,

Pr b−1 (T ) < θ < a−1 (T ) = 0.95




• Substitute observed value, t, to get an interval estimate,

b−1 (t), a−1 (t)




30 of 82
Challenge problem (exponential distribution)
Take a random sample of size n from an exponential distribution with
rate parameter λ.
1. Derive an exact 95% confidence interval for λ.
2. Suppose your sample is of size 9 and has sample mean 3.93.
2.1 What is your 95% confidence interval for λ?
2.2 What is your 95% confidence interval for the population mean?
3. Repeat the above using the CLT approximation (rather than an
exact interval).

31 of 82
Recap

• A point estimate is a single number that is our ‘best guess’ at the


true parameter value. In other words, it is meant to be the ‘most
plausible’ value for the parameter, given the data.
• However, this doesn’t allow us to adequately express our
uncertainty of this estimate.
• An interval estimate aims to provide a range of values that are
plausible based on the observed data. This allows us to more
adequately express our uncertainty of the estimate, by giving an
indication of the various plausible alternative true values.
• The most common type of interval estimate is a confidence
interval.

32 of 82
Graphical presentation of CIs
Draw CIs as ‘error bars’

There are various graphical styles that people use

● ● ● ●

33 of 82
Width of CIs
The width of a CI is controlled by various factors:
• inherent variation in the data
• choice of estimator
• confidence level
• sample size

For example, the width for the normal distribution example was:
σ
2c √
n

where c = Φ−1 (1 − α/2).

34 of 82
Interpreting CIs

• Narrower width usually indicates stronger/greater evidence about


the plausible true values for the parameter being estimated
• Very wide CI ⇒ usually cannot conclude much other than that
we have insufficient data
• Moderately wide CI ⇒ conclusions often depend on the location
of the interval
• Narrow CI ⇒ more confident about the possible true values, often
can be more conclusive
• What constitutes ‘wide’ or ‘narrow’, and how conclusive/useful the
CI actually is, will depend on the context of the study question

35 of 82
Three important distributions

• χ2 -distribution
• t-distribution
• F -distribution

36 of 82
Chi-squared distribution

• Also written in text as χ2 -distribution


• Single parameter: k > 0, known as the degrees of freedom
• Notation: T ∼ χ2k or T ∼ χ2 (k)
• The pdf is:
k t
t 2 −1 e− 2
f (t) = k , t≥0
2 2 Γ( k2 )
• Mean and variance:

E(T ) = k
var(T ) = 2k

• The distribution is bounded below by zero and is right-skewed

37 of 82
• Arises as the sum of iid standard normal rvs:

Zi ∼ N(0, 1) ⇒ T = Z12 + · · · + Zk2 ∼ χ2k

• When sampling from a normal distribution, the sample variance


follows a χ2 -distribution:

(n − 1)S 2
∼ χ2n−1
σ2

38 of 82
Student’s t-distribution

• Also known as simply the t-distribution


• Single parameter: k > 0, the degrees of freedom (same as for χ2 )
• Notation: T ∼ tk or T ∼ t(k)
• The pdf is:

− k+1
Γ( k+1 ) t2
 2
f (t) = √ 2 k 1+ , −∞ < t < ∞
kπ Γ( 2 ) k

• Mean and variance:

E(T ) = 0, if k > 1
k
var(T ) = , if k > 2
k−2

39 of 82
• The t-distribution is similar to a standard normal but with ‘wide’
tails
• As k → ∞, then tk → N(0, 1)
• If Z ∼ N(0, 1) and U ∼ χ2 (r), and they are independent, then

Z
T =p ∼ tr
U/r

• This arises when considering the sampling distributions of statistics


from a normal distribution, in particular:
X̄−µ

σ/ n X̄ − µ
T =q = √ ∼ tn−1
(n−1)S 2 S/ n
σ2
/(n − 1)

40 of 82
F -distribution

• Also known as the Fisher-Snedecor distribution


• Parameters: m, n > 0, the degrees of freedom (same as before)
• Notation: W ∼ Fm,n or W ∼ F(m, n)
• If U ∼ χ2m and V ∼ χ2n are independent then

U/m
F = ∼ Fm,n
V /n

• This arises when comparing sample variances (see later)

41 of 82
Pivots
Recall our general technique that starts with a probability interval
using a statistic with a known sampling distribution:

Pr (a(θ) < T < b(θ)) = 0.95

The easiest way to make this technique work is by finding a function


of the data and the parameters, Q(X1 , . . . , Xn ; θ), whose
distribution does not depend on the parameters. In other words, it
is a random variable that has the same distribution regardless of the
value of θ.

The quantity Q(X1 , . . . , Xn ; θ) is called a pivot or a pivotal quantity.

42 of 82
Remarks about pivots

• The value of the pivot can depend on the parameters, but its
distribution cannot.
• Since pivots are a function of the parameteres as well as the data,
they are usually not statistics.
• If a pivot is also a statistic, then it is called an ancillary statistic.

43 of 82
Examples of pivots

• We have already seen the following result for sampling from a


normal distribution with known variance:
X̄ − µ
Z= √ ∼ N(0, 1).
σ/ n

Therefore, Z is a pivot in this case.


• If we know the distribution of the pivot, we can use it to write a
probability interval, and start deriving a confidence interval.
• For example, in the normal case with known variance,
 
X̄ − µ
Pr a < √ <b
σ/ n

where a and b are fixed values that do not depend on µ.


44 of 82
Common scenarios: overview
Normal distribution: Proportions:
• Inference for a single mean • Inference for a single
◦ Known σ proportion
◦ Unknown σ
• Comparison of two
• Comparison of two means
proportions
◦ Known σ
◦ Unknown σ
◦ Paired samples
• Inference for a single variance
• Comparison of two variances

45 of 82
Normal, single mean, known σ
Random sample (iid): X1 , . . . , Xn ∼ N(µ, σ 2 ), and assume that we
know the value of σ.

We’ve seen this scenario already in previous examples.

Use the pivot:


X̄ − µ
Z= √ ∼ N(0, 1).
σ/ n

46 of 82
Normal, single mean, unknown σ
Random sample (iid): X1 , . . . , Xn ∼ N(µ, σ 2 ), and σ is unknown.

A pivot for µ in this case is:


X̄−µ

σ/ n X̄ − µ
T =q = √ ∼ tn−1
(n−1)S 2 S/ n
σ2
/(n − 1)

where tn−1 is the t-distribution with n − 1 degrees of freedom.

Now proceed as before.

47 of 82
Given α, let c be the (1 − α/2) quantile of tn−1 .
We then write:
 
X̄ − µ
Pr −c < √ < c = 1 − α.
S/ n

Rearranging gives:
 
S S
Pr X̄ − c √ < µ < X̄ + c √ =1−α
n n

and for observed x̄ and s, a 100 · (1 − α)% confidence interval for µ is


 
s s
x̄ − c √ , x̄ + c √ .
n n

48 of 82
Example (normal, single mean, unknown σ)
X ∼ N(µ, σ 2 ) is the amount of butterfat produced by a cow.
Examining n = 20 cows results in x̄ = 507.5 and s = 89.75. Let c be
the 0.95 quantile of t19 , we have c = 1.729. Therefore, a 90%
confidence interval for µ is,
 
89.75
507.50 ± 1.729 √ = [472.80, 542.20]
20

49 of 82
> butterfat
[1] 481 537 513 583 453 510 570 500 457 555 618 327
[13] 350 643 499 421 505 637 599 392

> t.test(butterfat, conf.level = 0.9)

One Sample t-test

data: butterfat
t = 25.2879, df = 19, p-value = 4.311e-16
alternative hypothesis: true mean is not equal to 0
90 percent confidence interval:
472.7982 542.2018
sample estimates:
mean of x
507.5

> sd(butterfat)
[1] 89.75082
> qqnorm(butterfat, main = "")
> qqline(butterfat, probs = c(0.25, 0.75))

This gives us the following QQ plot. . .

51 of 82
Sample Quantiles

350 400 450 500 550 600 650

52 of 82
−2
−1
0

Theoretical Quantiles
1
2
Remarks
• CIs based on a t-distribution (or a normal distribution) are of the
form:
estimate ± c × standard error
for an appropriate quantile, c, which depends on the sample size
(n) and the confidence level (1 − α).
• The t-distribution is appropriate if the sample is from a normally
distributed population.
• Can check using a QQ plot (in this example, looks adequate).
• If not normal but n is large, can construct approximate CIs using
the normal distribution (as we did in a previous example). This is
usually okay if the distribution is continuous, symmetric and
unimodal (i.e. has a single ‘mode’, or maximum value).
• If not normal and n small, distribution-free methods can be used.
We will cover these later in the semester.
53 of 82
Normal, two means, known σ
Suppose we have two populations, with means µX and µY , and want
to know how much they differ.

Random samples (iid) from each population:


2 ) and Y , . . . , Y ∼ N(µ , σ 2 )
X1 , . . . , Xn ∼ N(µX , σX 1 m Y Y

The two samples must be independent of each other.


2 and σ 2 are known.
Assume σX Y
Then we have the following pivot (why?):

X̄ − Ȳ − (µX − µY )
q
2 2
∼ N(0, 1)
σX σY
n + m

54 of 82
Defining c as in previous examples, we then write,
 
X̄ − Ȳ − (µX − µY )
Pr −c < q
2 2
< c = 1 − α
σX σY
n + m

Rearranging as usual gives the 100 · (1 − α)% confidence interval for


µX − µY as r
2
σX σ2
x̄ − ȳ ± c + Y
n m

. . . but it is rare to know the population variances!

55 of 82
Normal, two means, unknown σ, many samples
2 and σ 2 ?
What if we don’t know σX Y

If n and m are large, we can just replace σX and σY by estimates,


e.g. the sample standard deviations SX and SY .
Rationale: these will be good estimates when the sample size is large.

The (approximate) pivot is then:


X̄ − Ȳ − (µX − µY )
q
2
≈ N(0, 1)
SX SY2
n + m

This gives the following (approximate) CI for µX − µY :


r
s2X s2
x̄ − ȳ ± c + Y
n m
56 of 82
Normal, two means, unknown σ, common variance
But what if the sample sizes are small?
2 = σ 2 = σ 2 , we can find a
If we assume a common variance, σX Y
pivot, as follows.

Firstly,
X̄ − Ȳ − (µX − µY )
Z= q ∼ N(0, 1)
σ2 σ2
n + m

Also, since the samples are independent,


2
(n − 1)SX (m − 1)SY2
U= + ∼ χ2n+m−2
σ2 σ2
because U is the sum of independent χ2 random variables.
57 of 82
Moreover, U and Z are independent. So we can write,
Z
T =p ∼ tn+m−2
U/(n + m − 2)

Substituting and rearranging gives,

X̄ − Ȳ − (µX − µY )
T = q
SP n1 + m 1

where s
2 + (m − 1)S 2
(n − 1)SX Y
SP =
n+m−2
is the pooled estimate of the common variance.
Note that the unknown σ has disappeared (cancelled out), therefore
making T a pivot (why?).

58 of 82
We can now find the quantile c so that

Pr(−c < T < c) = 1 − α

and rearranging as usual gives a 100 · (1 − α)% confidence interval for


µX − µY : r
1 1
x̄ − ȳ ± c · sP +
n m
where s
(n − 1)s2X + (m − 1)s2Y
sP =
n+m−2

59 of 82
Example (normal, two means, unknown common
variance)
Two independent groups of students take the same test. Assume the
scores are normally distributed and have a common unknown
population variance.

We have sample sizes n = 9 and m = 15, and get the following


summary statistics: x̄ = 81.31, ȳ = 78.61, s2x = 60.76, s2y = 48.24.

The pivot has df 9 + 15 − 2 = 22 degrees of freedom. Using the 0.975


quantile of t22 , which is 2.074, the 95% confidence interval is:
r r
8 × 60.76 + 14 × 48.24 1 1
81.31 − 78.61 ± 2.074 +
22 9 15
= [−3.65, 9.05]

60 of 82
t density 22 df

Shaded
Probability is
95%

-2.074 2.074

61 of 82
Normal, two means, unknown σ, different variances
2 ̸= σ 2 ?
What if the sample sizes are small and pretty sure that σX Y

Then we can use Welch’s approximation:

X̄ − Ȳ − (µX − µY )
W = q
2
SX SY2
n + m

which approximately follows a tr -distribution with degrees of freedom


given by:
SY2 2
 2 
SX
n + m
r = S4 SY4
X
n2 (n−1)
+ m2 (m−1)
This is often the default for constructing confidence intervals.

62 of 82
Example (normal, two means, unknown different
variances)
We measure the force required to pull wires apart for two types of
wire, X and Y . We take 20 measurements for each wire.

1 2 3 4 5 6 7 8 9 10
X 28.8 24.4 30.1 25.6 26.4 23.9 22.1 22.5 27.6 28.1
Y 14.1 12.2 14.0 14.6 8.5 12.6 13.7 14.8 14.1 13.2

11 12 13 14 15 16 17 18 19 20
X 20.8 27.7 24.4 25.1 24.6 26.3 28.2 22.2 26.3 24.4
Y 12.1 11.4 10.1 14.2 13.6 13.1 11.9 14.8 11.1 13.5

63 of 82
30
25
20
15
10

X Y

64 of 82
Some heavily edited R output. . .

Different variances: Pooled variance:

> t.test(X, Y, > t.test(X, Y,


+ conf.level = 0.95) + conf.level = 0.95,
+ var.equal = TRUE)

t = 18.8003 t = 18.8003
df = 33.086 df = 38
95% CI: 11.23214 13.95786 95% CI: 11.23879 13.95121

65 of 82
Remarks

• From box plots: look like very different population means and
possibly different spreads
• The Welch approximate t-distribution is appropriate so a 95%
confidence interval is 11.23–13.96
• If we assumed equal variances, the confidence interval becomes
slightly narrower, 11.24–13.95
• Not a big difference!

66 of 82
Normal, paired samples

• As before, we are interested in the difference between the means of


two sets of observations, µD = µX − µY
• This time, we observe the measurements in pairs,
(X1 , Y1 ), . . . , (Xn , Yn )
• Each pair is observed independently of each other pair, but the
members of each pair could be related
• We can exploit this extra information (the relationship within
pairs) to both simplify and improve our estimate
• Let Di = Xi − Yi be the differences of each pair
2)
• Often reasonable to assume Di ∼ N(µD , σD

67 of 82
• We can now use our method of inference for a single mean!
• A 100 · (1 − α)% confidence interval for µD is:

sd sample Standard deviation of the


d¯ ± c √ differences
n

where c is the 1 − α/2 quantile of tn−1 .

68 of 82
Example (normal, paired samples)
Summary statistics:
The reaction times (in seconds) to a red or n = 8,
green light for 8 people are given in the d¯ = 0.0125,
following table. Find a 95% CI for the mean sd = 0.129
difference in reaction time.
Red (X) Green (Y ) D =X −Y
1 0.30 0.24 0.06 95% CI:
2 0.43 0.27 0.16
3 0.23 0.36 −0.13
0.129
0.0125 ± 2.365 √
4 0.32 0.41 −0.09 8
5 0.41 0.38 0.03 = [−0.095, 0.12]
6 0.58 0.38 0.20
7 0.53 0.51 0.02 (2.365 is the 0.975
8 0.46 0.61 −0.15 quantile of t7 )

69 of 82
Normal, single variance
Random sample (iid): X1 , . . . , Xn ∼ N(µ, σ 2 )

This time we wish to infer σ, rather than µ

A pivot for σ is:


(n − 1)S 2
∼ χ2n−1
σ2

Now we need the α/2 and 1 − α/2 quantiles of χ2n−1 .


Call these a and b. In other words,

(n − 1)S 2
 
Pr a < <b =1−α
σ2

70 of 82
Rearranging gives
 
a 1 b
1 − α = Pr < 2 <
(n − 1)S 2 σ (n − 1)S 2
(n − 1)S 2 (n − 1)S 2
 
2
= Pr <σ <
b a

So a 100 · (1 − α)% confidence interval is

(n − 1)s2 (n − 1)s2
 
,
b a

71 of 82
Example (normal, single variance)
Sample n = 13 seeds from a N(µ, σ 2 ) population.

Observe a mean sprouting time of x̄ = 18.97 days, and sample


variance s2 = 128.41/12.

A 90% confidence interval for σ 2 is:


 
128.41 128.41
, = [6.11, 24.6]
21.03 5.226

with the 0.05 and 0.95 quantiles from a χ212 distribution being 5.226
and 21.03.

72 of 82
Normal, two variances
Now we wish to compare the variances of two normally distributed
populations. Random samples (iid) from each population:
2 ) and Y , . . . , Y ∼ N(µ , σ 2 )
X1 , . . . , Xn ∼ N(µX , σX 1 m Y Y

2 /σ 2 . Start by defining:
We will compute a confidence interval for σX Y

SY2 (m−1)SY2
h i
2
σY 2
σY
/(m − 1)
2
SX
= h 2
(n−1)SX
i
σ2 σ2
/(n − 1)
X X

This is the ratio of independent χ2 random variables divided by their


degrees of freedom and hence has an Fm−1,n−1 distribution. This
doesn’t depend on the parameters and is thus a pivot.

73 of 82
We now need the α/2 and 1 − α/2 quantiles of Fm−1,n−1 .
Call these c and d. In other words,

SY2 /σY2 2
SX 2
σX 2
SX
1 − α = Pr(c < 2 /σ 2 < d) = Pr(c < < d )
SX X SY2 σY2 SY2
2 /σ 2 as
Rearranging gives the 100 · (1 − α)% confidence interval for σX Y
 2
s2

s
c x2 , d x2
sy sy

74 of 82
Example (normal, two variances)
Continuing from the previous example, n = 13 and 12s2x = 128.41.
A sample of m = 9 seeds from a second strain gave 8s2y = 36.72.

The 0.01 and 0.99 quantiles of F8,12 are 0.176 and 4.50.

Then a 98% confidence interval for σX 2 /σ 2 is


Y
 
128.41/12 128.41/12
0.176 , 4.50 = [0.41, 10.49]
36.72/8 36.72/8

Not very useful! Too wide.

75 of 82
Single proportion

• Observe n Bernoulli trials with unknown probability p of success,

X1 , X2 , . . . , Xn ∼ Be(p)

• We want a confidence interval for p


• Recall that the sample proportion of successes p̂ = X̄ is the
maximum likelihood estimator for p and is unbiased for p

76 of 82
• The central limit theorem shows for large n,

p̂ − p
p ≈ N (0, 1)
p(1 − p)/n

• Rearranging the corresponding probability statement as usual and


estimating p by p̂ gives the approximate 100 · (1 − α)% confidence
interval as r
p̂(1 − p̂)
p̂ ± c
n

77 of 82
Example (single proportion)

• In the Newspoll of 3rd April 2017, 36% of 1,708 voters sampled


said they would vote for the Government first if an election were
held on that day. What is a 95% confidence interval for the
population proportion of voters who would vote for the
Government first?
• The sample proportion has an approximate normal distribution
since the sample size is large so the required confidence interval is:
r
0.36 × 0.64
0.36 ± 1.96 = [0.337, 0.383]
1708
• It might be nice to round to the nearest percentage for this
example. This gives us the final interval: 34%–38%

78 of 82
Example 2 (single proportion)

• In a survey, y = 185 out of n = 351 voters favour a particular


candidate. Note that 185/351 = 0.527. An approximate 95%
confidence interval for the proportion of the population supporting
the candidate is
r
0.527 × 0.473
0.527 ± 1.96 = [0.475, 0.579]
351
• The candidate is not guaranteed to win despite p̂ > 0.5!

79 of 82
Two proportions

• We now wish to compare proportions between two different


samples: Y1 ∼ Bi(n1 , p1 ), Y2 ∼ Bi(n2 , p2 )
• Use the approximate pivot

p̂ − p̂2 − (p1 − p2 )
q1 ≈ N(0, 1)
p1 (1−p1 ) p2 (1−p2 )
n1 + n2

• This gives the approximate CI


s
p̂1 (1 − p̂1 ) p̂2 (1 − p̂2 )
p̂1 − p̂2 ± c +
n1 n2

80 of 82
Example (two proportions)
Following on from the previous Newspoll example. . .
• At the previous poll, with 1,824 voters sampled, there were 37% of
voters who reported that they would vote for the Government first.
Has the vote dropped? What is a 90% confidence interval for the
difference in proportions in the population on the two occasions?
• The CI is
r
0.36 × 0.64 0.37 × 0.63
0.36−0.37±1.6449 + = [−0.037, 0.017]
1708 1824
• This interval comfortably surrounds 0, meaning there is no
evidence of a change in public opinion.
• This analysis allows for sampling variability in both polls, so is the
preferred way to infer whether the vote has dropped.
81 of 82
Example 2 (two proportions)
Two detergents. First successful in 63 out of 91 trials, the second in
42 out of 79.

Summary statistics: p̂1 = 0.692, p̂2 = 0.532

90% confidence interval for the difference in proportions is:


r
0.692 × 0.308 0.532 × 0.468
0.692 − 0.532 ± 1.645 +
91 79
= [0.038, 0.282]

Very wide! Need greater sample size to get more certainty.

82 of 82

You might also like