Inferential statistics

advertisement
Inferential Statistics Part 1
Chapter 8
P. 253- 278
Collecting a random sample
Goal: to understand characteristics about a
population
Examples:
What’s the average commuting time for city residents?
What’s the average household income of the patrons of a
particular grocery store?
What’s the average leaf size size of birch trees on August 1
in a particular state park?
What proportion of people in a particular tropical city have
had malaria?
Estimating the mean
One of the most common goals of statistical
inference is estimating a population mean
with a sample mean
Central Limit Theorem
When we have n independent, identically distributed
(X1..Xn) random variables, the mean of those random
variables approaches a normal distribution with mean
= μ and variance = 2 , as n gets large.
n
Independence of random variables means that the
value of one observation has no effect on the value
of another observation.
Identical distribution of random variables means that
each random variable comes from the same
population (e.g., roll of a die, coin flip).
Simple random sampling
Each observation drawn does not depend on others
drawn
Thus observations are independent
Each observation (i.e., each random variable) is
identically distributed
The population has a distribution that doesn’t change (each
observation is randomly drawn from an identical distribution
– the distribution of the population).
So the Central Limit Theorem applies!
(when n is large)
What does this mean?
Suppose we take a sample of n=50
observations from a population that
has this distribution:
frequency
0
10
20
30
Mean (μ) = 20
2
Variance (
) = 100
Std. dev (
) = 10
We then find the mean of this sample (suppose this mean = 19). Take
another sample of 50 observations and find the mean (suppose it’s 24).
Do this many times, and we’ll come up with a distribution of means. The
Central Limit Theorem tells us this distribution will always look like the next
slide (as long as n is “large”, and 50 is large enough):
The normal curve
16
18
20
22
24
x
Mean (μ) = 20
Sample size (n) = 50
2
variance of sample mean =
n
=2
Symbols
Population Parameter: 
Estimate:
ˆ
Expected:
E (ˆ )
Basic Types of Inference
Point Inference
The value of a population parameter
single value
̂
 is estimated using a
Examples: mean, standard deviation, etc.
Interval Inference
Attaching a probability to an estimate (i.e., making a
confidence interval)
Example: we are 95% confident that μ is between 10 and 20
Judging the Quality of the Estimator
ˆ )and
Bias – the difference between E (
ˆ ) )
(i.e., Bias  E (

Bias may be positive or negative (e.g., a
positively biased estimator would indicate the
population parameter is higher than it actually
is)
Efficiency – how clustered the distribution of
is (i.e., how “peaked” is its distribution)
̂
Judging the Quality of the Estimator
Best case scenario: to have an unbiased estimator,
with a high level of efficiency
We can measure the quality of the estimator using
the Mean Squared Error (MSE) or its counterpart
RMSE (the square root of the MSE)
MSE  Bias  Variance
2
Remember that the variance in this case it the
variance of a random variable so we use the
equation:
2
Variance 
n
Point Estimates (inferring population
parameters from samples)
Population Mean:
x
Population Proportions:
  P  X /n
Population Variance:
 2  s2
Population Standard Deviation:
 s
Confidence Intervals
The degree of confidence we have in our estimates defined
by a percentage
Common examples: 90, 95, or 99% confident
The confidence interval is defined with the α symbol
In confidence intervals, alpha (α) is the proportion of time
your confidence interval is wrong
The typical usage is:
z / 2
Why do we divide by 2?
Confidence Interval Example
What is the 95% confidence interval for a normally distributed
variable?
α= 1 - desired confidence interval
α= 1 – 0.95 = 0.05
Remember that we divide α by 2 since we have uncertainty both
above and below the mean (i.e., 2 tails)
Therefore we use z0.025 for the 95% confidence interval
From the z-table we find that z0.025 = 1.96
What does this mean?
Interval Estimation (making confidence intervals
for population parameters estimated from samples)
Case #1 estimating an interval for μ when X
is normally distributed and we know σ
This is the simplest case because normality
allows us to use the z-table
This is also unlikely since it requires knowing
the distribution and the σ (which implies
knowing μ already)
Example #1: Create a confidence
interval for μ
A town is considering building a new bridge over a
river. The primary goal is to reduce workers’
commute times from a particular community. A
random sample of workers in that community are
asked to estimate their reduction in commute time if
the bridge were built.
Our goal is to estimate the mean reduction in
commute time for the whole community if the bridge
were built. Create a 95% confidence interval for this
mean.
Example #1 Data
n = 100 workers are sampled
x = 17 minutes
σ = 30 minutes
What is the 95% confidence interval for
the mean?
Constructing a confidence interval
Construct a 95% confidence interval around the sample mean
P ( X  1.96

n
   X  1.96

n
)  0.95
30
30
P (17  1.96
   17  1.96
)  0.95
100
100
P (17  1.96 * 3    17  1.96 * 3)  0.95
P (17  5.88    17  5.88)  0.95
So we can say that the 95% C.I. is 17 +/- 5.88 or 11.12, 22.88
Example #1 Questions
What would happen to our interval if we
used a 99% confidence interval
instead?
What would happen to our confidence
interval if we sampled 200 people
instead of 100 people?
Interval Estimation (making confidence intervals
for population parameters estimated from samples)
Case #2 estimating an interval for μ when X
is not normally distributed and we know σ
In this case the n matters a lot, why?
This is also unlikely since it requires knowing
the distribution and the σ (which implies
knowing μ already)
Interval Estimation (making confidence intervals
for population parameters estimated from samples)
Case #3 estimating an interval for μ when σ
and the distribution are unknown
What should we used instead of σ?
Can we use the z-table in this case?
This case is what we see most commonly
t-distribution vs. z-distribution
When we only have s (and not σ) we use the tdistribution rather than the z-distribution
To do so we use the t-table
How are they different?
The t-distribution changes depending on the degrees of
freedom (n-1)
• This is reflected in the table and in the symbol
t / 2 ,n 1
The t-distribution accounts for more uncertainty (i.e., wider
confidence intervals) since s is just an estimate for σ
t-distribution vs. z-distribution
As n approaches infinity t and z become equal
This means that even when we have s instead of σ we can use the zdistribution if n is large
Central Limit Theorem: “…as n gets large.”
What is “large”?
Rule of thumb: 30
For n less than 30, the distribution of x does not follow the normal
distribution accurately enough.
But the distribution of x does closely follow a t-distribution for sample
sizes of less than 30.
For this class use the t-distribution any time you have s instead of σ
Example #2
n = 16
x = 30
s2 = 1600
What is the 95% C.I. for the mean?
Example #2
s = 40
Degrees of freedom = n – 1 = 15
t / 2,n 1  t0.05 / 2,161  t0.025,15  2.131 (from the t-table)
P( X  2.131
s
P(30  2.131
40
n
   X  2.131
16
s
   30  2.131
n
)  0.95
40
16
)  0.95
P(30  2.131 *10    30  2.131 *10)  0.95
P(30  21.31    30  21.31)  0.95
The 95% confidence interval for the mean is (8.69, 51.31)
Interval Estimation (making confidence intervals for
population parameters estimated from samples)
Case #4 estimating an interval for a proportion π
based on a sample proportion p
Remember that p = x/n
In other word, p = the number of “successes” divided by
the number of samples
For example: the proportion of people over 6ft tall
In this case we don’t need s or σ, but we do need
the standard deviation of p:
 (1   )
p 
Which we estimate as:
sp 
n
p(1  p)
n
Interval Estimation (making confidence intervals for
population parameters estimated from samples)
Case #4 continued
Equation:
p  z / 2
p(1  p)
p(1  p)
   p  z / 2
n
n
We use the z-distribution for estimating an interval for a
proportion π based on a sample proportion p
This also limits us to using only large samples (in this case n
> 100)
For smaller samples, we calculate the entire distribution using
the binomial mass function: P ( x)  C xn x (1   ) n  x (i.e., solve
for all x values)
Example #3
n = 150 people at a convention
63 people sampled were over 6 feet tall
What is the 99% C.I. for the true
proportion of all people ≥6 ft tall at the
convention?
Example #3
p = 63/150 = 0.42
99% C.I. -> z

 /2
p  z / 2
z0.005  2.58
p (1  p)
   p  z / 2
n
0.42  2.58
(from the z-table)
p(1  p)
n
0.42 * 0.58
0.42 * 0.58
   0.42  2.58
150
150
0.42  2.58 * 0.04    0.42  2.58 * 0.04
0.42  0.104    0.42  0.104
The 99% confidence interval for p = 0.42 is (0.316, 0.524)
Sample Size Determination
Often, before we conduct a sample, we want to know
how large of a sample we need
Required sample sizes can be determined for
population parameters (mean, proportions, etc.) by
modifying the equations we’ve been going through
An additional component is the error (E)
This is basically the term that defines how far off we are
willing to be (i.e., the margin of acceptable error)
Strictly speaking, E is one-half the difference between the
upper and lower values for an interval for a given C.I.
Note that E is not the same as C.I.
Sample Size Determination
 z / 2 
Equation for μ : n  

 E 
Equation for π:
2
 z / 2 p(1  p) 

n


E


What obvious flaw do you see?
2
Example #4
A movie theatre wants to know the mean
number of tickets sold per day. How many
days must they count to know the mean daily
ticket sales within 100 tickets with a 95%
confidence interval?
From previous sales reports, it is determined
that σ = 175
Example #4
What numbers do we plug into
our equation?
What should zalpha/2 be?
What should E be?
Why don’t we multiply this by 2?
What should σ be?
 z / 2 
n

 E 
2
Example #4
z = 1.96
E = 100
σ = 175
n = number of days
we should sample
 z / 2 
n

 E 
2
 1.96 *175 
n

 100 
2
 1.96 *175 
n

 100 
2
n  11.765
Example #5
A city council election is being held with several
candidates expecting reasonably large returns.
To avoid a run-off between the top 2 vote getters,
the leading candidate must receive at least 45% of
the vote
How many people do we need to sample using exit
polls to determine with 99% confidence and an
acceptable error of 0.005 whether there will be a
run-off vote?
Example #5
z = 2.58
E = 0.005
p = 0.45
n = number of
people we should
sample
 z / 2 p (1  p ) 

n


E


2
 2.58 * 0.45 * 0.55 

n  

0.005


 2.58 * 0.497 
n

 0.005 
n  16310
2
2
Class Problem
Given this sample of middle school kid
heights (in inches)
56, 64, 52, 69, 66, 64, 63, 46, 46, 49, 47,
60, 54, 45, 45, 69, 62, 67, 49, 43, 59
What is the 99% confidence interval for
the population mean (μ)?
Solution
n = 21
x = 1175/21 = 55.95
s = 8.96
talpha/2 , n-1 = 2.845
P( X  2.845
s
n
P(55.95  2.845
   X  2.845
8.96
21
s
n
)  0.99
   55.95  2.845
8.96
21
)  0.99
P(55.95  5.563    55.95  5.563)  0.99
So the 99% C.I. for the population mean (μ) is [50.387, 61.513]
For Friday
Come with questions about homework
#6
For Monday
Read chapter 9 : pages 280-306
Download