Download Part IV - The University of Edinburgh

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Sufficient statistic wikipedia , lookup

History of statistics wikipedia , lookup

Foundations of statistics wikipedia , lookup

Degrees of freedom (statistics) wikipedia , lookup

Confidence interval wikipedia , lookup

Bootstrapping (statistics) wikipedia , lookup

German tank problem wikipedia , lookup

Taylor's law wikipedia , lookup

Misuse of statistics wikipedia , lookup

Resampling (statistics) wikipedia , lookup

Student's t-test wikipedia , lookup

Transcript
Basic Statistics for SGPE Students
Part IV: Statistical inference1
Mark Mitchell
Nicolai Vitt
[email protected]
[email protected]
University of Edinburgh
September 2016
1
Thanks to Achim Ahrens, Anna Babloyan and Erkal Ersoy for creating
these slides and allowing us to use them.
Outline
1. Descriptive statistics
I
I
I
I
Sample statistics (mean, variance, percentiles)
Graphs (box plot, histogram)
Data transformations (log transformation, unit of measure)
Correlation vs. Causation
2. Probability theory
I
I
Conditional probabilities and independence
Bayes’ theorem
3. Probability distributions
I
I
I
I
Discrete and continuous probability functions
Probability density function & cumulative distribution function
Binomial, Poisson and Normal distribution
E[X] and V[X]
4. Statistical inference
I
I
I
I
I
Population vs. sample
Law of large numbers
Central limit theorem
Confidence intervals
Hypothesis testing and p-values
1 / 41
Introduction
Recall, in the last lecture we assumed that we know the probability
distribution of the random variable in question as well as the parameters
of the distribution (e.g. µ and σ 2 for the normal distribution). Under
these assumptions we were able to obtain the probability that the random
variable would take values within a particular interval (e.g. P(X ≤8)).
0.5
N(0, 1)
N(0, 2)
N(0, 3)
0.4
f (x)
0.3
0.2
0.1
0
What if we don’t know µ?
−4
−2
0
2
4
x
2 / 41
Population vs. sample
Suppose we are interested in the distribution of heights in the UK. The
residents of the UK are the population; the parameter µ is the true
average height of UK residents and σ 2 the true variance.
If we were to measure the height of all UK residents, we would conduct a
census. However, measuring the height of every individual is hardly
feasible, or only at an exorbitant cost. Instead, we can randomly select a
sample from the population and make inferences from the sample to the
population.
In particular, we can use the sample statistics (e.g. sample mean and
sample variance) to make inferences about the true, but unknown
population parameters (µ and σ 2 ).
3 / 41
Population vs. sample
We randomly select a sample from the UK population and measure the
heights of the individuals in the sample.
Simple random sample
A random sample is given if each individual in the population has an
equal chance of being chosen.
Since the draws are random, the height of the first, second, third, . . . nth
selected individual is random, too. That is, X1 , X2 , . . . , Xn are random
variables.
I.I.D.
Suppose we draw n items (X1 , X2 , . . . , Xn ) at random from the same
population. Since X1 , X2 , . . . , Xn are drawn from the same population,
they are identically distributed. Furthermore, since the distribution of Xi
does not depend on the distribution of Xj (for i, j = 1, . . . , n; i 6= j), we
can say that they are independently distributed. We say that
X1 , X2 , . . . , Xn are independently and identically distributed (i.i.d.).
4 / 41
Population vs. sample
Now, we draw (n=10, in cm)
182 197 183 171 171 162 152 157 192 174
Given this sample, what is our best guess about µ? It’s just the sample
mean.
n
X
1
x̄ =
xi =
(182 + · · · + 174) = 174.1
10
i=1
The sample mean is an unbiased and consistent estimator of the
unknown population mean µ.
Unbiasedness vs. consistency
To understand unbiasedness, note that the sampling distribution of x̄ is
centered at µ. When we repeatedly sample (more on this in a bit), x̄ is
sometimes above the true value of the parameter µ and sometimes below
it. However, the key aspect here is that there is no systematic tendency
to overestimate or underestimate the true parameter. This makes x̄ an
unbiased estimator of the parameter µ.
5 / 41
Population vs. sample
Now, we draw (n=10, in cm)
182 197 183 171 171 162 152 157 192 174
Given this sample, what is our best guess about µ? It’s just the sample
mean.
n
X
1
x̄ =
xi =
(182 + · · · + 174) = 174.1
10
i=1
The sample mean is an unbiased and consistent estimator of the
unknown population mean µ.
Unbiasedness vs. consistency
An estimator is consistent if, as the sample size increases, the estimator
converges to the true population parameter.
5 / 41
The Law of Large Numbers
Although x̄ is rarely exactly right and varies from sample to
sample, it is still a reasonable (and in fact, the best) estimate of
the population mean, µ.
This is because it is guaranteed to get closer to the population
parameter µ as the sample size increases. Therefore, we know that
if we could keep taking measurements from more subjects,
eventually we would estimate the true population mean very
accurately.
This fact is usually referred to as the law of large numbers. It is a
remarkable fact because it holds for any population.
Law of Large Numbers
If we randomly draw independent observations from any population
with finite mean µ, the sample mean, x̄, of the observed values
approaches the true mean, µ, of the population as the number of
observations, n, goes to ∞.
6 / 41
97
98
Mean of first n observations
99
100
101
LLN in Action
1
5
10
50
100
500
Number of observations, n
1000
5000 10000
7 / 41
LLN in Action
97
98
Mean of first n observations
100
99
101
In the diagram on the previous slide (reproduced below), we have
plotted the mean of the first n observations in our (artificially
generated) data set of 10,000 observations. More specifically, we
generated a normally distributed variable with mean, µ, 100 and
standard deviation, σ, 4. Then, to obtain each plotted point, we
calculated the mean of the generated figures up to each n.
1
5
10
50
100
500
Number of observations, n
1000
5000 10000
7 / 41
Population vs. sample
The sample mean estimator X̄ is a function of X1 , . . . , Xn ,
X̄ =
n
1 X
Xi .
N i=1
Therefore, it is a random variable, whereas the sample mean of our
sample, x̄ = 174.1, is a realisation.
Estimator vs. estimate
An estimator is a function of random variables which represent draws
from a population. Thus, the estimator is a random variable. The
estimator works like a method or formula for "guessing" population
parameters. An estimate, on the other hand, is the numerical value that
you obtain from a specific sample. An estimate is not a random variable,
it’s just a number.
As any other random variable, X̄ follows a distribution. What does the
distribution look like? To answer this question, we consider one of the
most remarkable theorems in statistics, the central limit theorem.
8 / 41
Central limit theorem
Let’s demonstrate the CLT using a simulation. We assume that
Xi ∼ i.i.d. uniform(160, 180). That is, we assume that the Xi ’s are
uniformly distributed within the interval [160, 180].
We proceed as follows:
1. We draw n = 50 observations (x1 , . . . , x50 ) from our “population”
(in this case: from our uniform distribution).
2. We obtain and write down the sample mean (i.e. x̄).
3. Repeat step (1) and (2) 10,000 times.
This gives us 10,000 sample means (x̄ (1) , x̄ (2) , . . . , x̄ (10,000) ). This large
set of sample means should give us an idea how the theoretical
distribution of X̄ looks like.
9 / 41
CLT in Action
0
.1
.2
Density
.3
.4
.5
.6
100 repetitions
166
168
170
Sample mean
172
174
10 / 41
CLT in Action
0
.1
.2
Density
.3
.4
.5
.6
5000 repetitions
166
168
170
Sample mean
172
174
10 / 41
CLT in Action
0
.1
.2
Density
.3
.4
.5
.6
10000 repetitions
166
168
170
Sample mean
172
174
10 / 41
Central limit theorem
0
.1
.2
Density
.3
.4
.5
.6
10000 repetitions
166
168
170
Sample mean
172
174
The sample mean of x̄ (1) , x̄ (2) , . . . , x̄ (10,000) is 170.0007 and the standard
deviation is 0.8139225.
11 / 41
The mean and the standard deviation of x̄
If x̄ is the mean of a sample of size n, which are drawn randomly from a
large sample with mean µ and standard deviation σ, then the mean of
the sampling distribution of x̄ is µ and its standard deviation is √σn .
More formally, the central limit theorem can be described as follows.
Central limit theorem
Suppose you draw n random numbers from an arbitrary (discrete or
continuous) distribution with mean µ and variance σ 2 . If n is sufficiently
large, then
σ2
X̄ ∼ N µ,
n
Pn
1
where X̄ = n i=1 Xi .
12 / 41
Short digression: The expected value of X̄
X̄ =
N
X
1
i=1
N
Xi =
1
1
1
1
X1 + X2 + X3 + · · · + XN
N
N
N
N
From last lecture, we know that the expectation of a sum is the
sum of the expectations and thus:
E(X̄ ) = E[
N
X
1
i=1
N
Xi ] = E[
1
1
1
X1 ] + E[ X2 ] + · · · + E[ XN ]
N
N
N
1
1
1
E[X1 ] + E[X2 ] + · · · + E[XN ]
N
N
N
1
1
1
= µ + µ + ··· + µ
N
N
N
=µ
=
13 / 41
Short digression: The variance of X̄
V[X̄ ] = V[
N
X
1
i=1
N
Xi ] = V[
1
1
1
1
X1 + X2 + X3 + · · · + XN ]
N
N
N
N
1
1
1
V[Y1 ] + 2 V[Y2 ] + · · · + 2 V[YN ]
N2
N
N
1
1
1
= 2 σ2 + 2 σ2 + · · · + 2 σ2
N
N
N
σ2
=
N
=
This result tells us that the sample variance decreases as the sample size
increases.
14 / 41
Making statistical inferences
Confidence intervals
Recall the following diagram from the first lecture, where we
indicated that 95% of the values in a given data set tends to lie
within 2 standard deviations from the mean (for normally
distributed variables).
68%
mean
mean - one SD
mean + one SD
95%
mean
mean - two SDs
mean + two SDs
We can use this observation to make statistical inferences.
15 / 41
Making statistical inferences
Confidence intervals
0.5
N (0, 1)
0.4
f (x)
0.3
0.2
0.1
0
−4
−2
0
2
4
x
16 / 41
Making statistical inferences
Confidence intervals
As discussed earlier, the sample mean x̄ is an appropriate estimator of the
unknown population mean µ because it is an unbiased estimator of µ,
and it approaches the true population parameter as sample size increases.
We have also mentioned, however, that this estimate varies from sample
to sample. So, how reliable is this estimator? To answer this question, we
need to consider the spread as well. From the central limit theorem
(CLT), we know that if the population mean is µ and the standard
deviation is σ, then repeated samples of n observationsshouldyield a
2
sample mean x̄ with the following distribution: X̄ ∼ N µ, σn .
Confidence Interval
A confidence interval with confidence level C consists of two parts:
1. An interval obtained from the data in the form
estimate ± margin of error
2. A chosen confidence level, C , which gives the probability that the
calculated interval will contain the true parameter value.
17 / 41
Confidence Intervals
Calculating the interval
One of the most popular values for C is 95%, which (obviously)
leads to a 95% confidence interval—meaning there’s 95%
probability that the true population parameter lies within that
confidence interval (CI).
95% Confidence Interval
To get a 95% CI for a population mean (µ), we simply need to do:
σ
x̄ ± z × √
n
where z is the critical value with area C between −z and z under
the standard normal curve. The right part of the expression (i.e.
z × √σn ) is the margin of error.
18 / 41
Confidence Intervals
Calculating the interval
Example
Suppose a student measuring the boiling temperature of a certain liquid
observes the readings (in degrees Celsius) 102.5, 101.7, 103.1, 100.9,
100.5, and 102.2 on 6 different samples of the liquid. He calculates the
sample mean to be 101.82. If he knows that the standard deviation for
this procedure is 1.2 degrees, what is the confidence interval for the
population mean at a 95% confidence level?
In other words, the student wishes to estimate the true mean boiling
temperature of the liquid using the results of his measurements. If the
measurements follow a normal distribution, then the sample mean will
2
have the distribution N (µ, σn ). Since the sample size is 6, the standard
1.2
deviation of the sample mean is equal to √
= 0.49.
6
Then, the 95% CI is simply
101.82 ± 1.96 × 0.49 = [100.86, 102.78]
19 / 41
Confidence Intervals
Calculating the interval
Example
Suppose a student measuring the boiling temperature of a certain liquid
observes the readings (in degrees Celsius) 102.5, 101.7, 103.1, 100.9,
100.5, and 102.2 on 6 different samples of the liquid. He calculates the
sample mean to be 101.82. If he knows that the standard deviation for
this procedure is 1.2 degrees, what is the confidence interval for the
population mean at a 95% confidence level?
If we wanted to construct a 99% CI, however, our critical values would
change. This would also change our CI itself:
101.82 ± 2.56 × 0.49 = [100.57, 103.07]
19 / 41
Confidence Intervals
Behaviour of confidence intervals
Confidence intervals get
smaller as:
1. The number of
observations, n,
increases
2. The level of
confidence
decreases
20 / 41
Tests of Significance
Why we need them (and some terminology)
Significance tests are a formal way for us to draw conclusions
about a statement using observed data. These tests are the tools
we use to investigate whether the data corroborate the hypothesis
that is being put forth. A hypothesis is a statement about the
parameters in a population or model.
Null hypothesis, H0
The statement or hypothesis being tested in a significance test is
called the null hypothesis, and is normally referred to as H0 . The
significance tests assess the evidence for and against this
hypothesis and allow us to either reject or fail to reject H0 .
Consider the following example to see how we can put these to use.
21 / 41
Tests of Significance
Example: Are the bottles being filled as advertised?
Suppose we are appointed as inspectors at an Irn Bru factory here in Scotland.
We have data on past production and observe that the distribution of the
contents is normal with standard deviation of 2ml. To assess the bottling
process, we randomly select 10 bottles, measure their contents and obtain the
following results:
502.9 499.8 503.2 502.8 500.9 503.9 498.2 502.5 503.8 501.4
For this sample of observations, the mean content, x̄, is 501.94 ml. Is this
sample mean far enough from 500 ml to provide convincing evidence that the
mean content of all bottles produced at the factory differ from the advertised
amount of 500 ml?
22 / 41
Tests of Significance
Example: Are the bottles being filled as advertised?
The randomly selected bottles resulted in the following measurements (and
recall that σ = 2).
502.9 499.8 503.2 502.8 500.9 503.9 498.2 502.5 503.8 501.4
For this sample of observations, the mean content, x̄, is 501.94 ml. Is this
sample mean far enough from 500 ml to provide convincing evidence that the
mean content of all bottles produced at the factory differ from the advertised
amount of 500 ml?
Two incorrect ways of approaching this question is to say:
1. The mean of the sampled bottles is different from 500 ml, so the process
is not filling the bottles at the correct mean level.
2. The difference of 1.94 ml is small relative to 500 ml, so this result is not
surprising and the process is working well.
22 / 41
Tests of Significance
Example: Are the bottles being filled as advertised?
The randomly selected bottles resulted in the following measurements (and
recall that σ = 2).
502.9 499.8 503.2 502.8 500.9 503.9 498.2 502.5 503.8 501.4
For this sample of observations, the mean content, x̄, is 501.94 ml. Is this
sample mean far enough from 500 ml to provide convincing evidence that the
mean content of all bottles produced at the factory differ from the advertised
amount of 500 ml?
Instead, we should formulate our null hypothesis and the "competing" or
"alternative" hypothesis, and conduct a formal test of significance. In this
example,
H0 : µ = 500 and Ha : µ 6= 500
And all we are missing is a test statistic that will help us assess how much
evidence there is towards the null hypothesis.
22 / 41
Tests of Significance
Example: Are the bottles being filled as advertised?
The randomly selected bottles resulted in the following measurements (and
recall that σ = 2).
502.9 499.8 503.2 502.8 500.9 503.9 498.2 502.5 503.8 501.4
For this sample of observations, the mean content, x̄, is 501.94 ml. Is this
sample mean far enough from 500 ml to provide convincing evidence that the
mean content of all bottles produced at the factory differ from the advertised
amount of 500 ml?
To obtain the test statistic, we simply use the standardised version of x̄:
z=
x̄ − µ
√σ
n
=
501.94 − 500
√2
10
= 3.07(> 1.96)
We already know that 3.07 is quite far away from the mean of the standard
normal distribution (which is, of course, 0). In fact, 95% of the area under the
standard normal curve lies within [−1.96, 1.96]. Therefore, using the observed
sample of 10 bottles, we reject H0 and conclude that our data are not
compatible with H0 .
22 / 41
Tests of Significance
Example: Are the bottles being filled as advertised?
The randomly selected bottles resulted in the following measurements (and
recall that σ = 2).
502.9 499.8 503.2 502.8 500.9 503.9 498.2 502.5 503.8 501.4
For this sample of observations, the mean content, x̄, is 501.94 ml. Is this
sample mean far enough from 500 ml to provide convincing evidence that the
mean content of all bottles produced at the factory differ from the advertised
amount of 500 ml?
To obtain the test statistic, we simply use the standardised version of x̄:
z=
x̄ − µ
√σ
n
=
501.94 − 500
√2
10
= 3.07(> 1.96)
Even more formally, we say "we reject the null hypothesis at the
5% level."
22 / 41
Tests of Significance
P-values
As we mentioned earlier, test statistics provide us with a measure
of evidence against the null hypothesis. The farther away the
observations from what we would expect if the H0 were true, the
more evidence there is against H0 . The z-statistic we calculated
earlier is one way of measuring how far the data are from what we
would expect, which is what allows us to draw conclusions about
the hypotheses.
Another way to quantify how far away from what we expect the
data are is using a p-value.
P-value
The p-value is the probability that the corresponding test statistic
would take a value as or more extreme than that is actually
observed assuming H0 is true. Hence, the smaller the p-value,
the stronger the evidence in the data against H0 being true.
23 / 41
Tests of Significance
Calculating p-values
Consider our earlier example about the Irn Bru factory, where we
calculated the z-statistic to be 3.07 using our sample of size
n = 10, standard deviation of 2 ml and the sample mean
x̄ = 501.94:
z=
x̄ − µ
√σ
n
=
501.94 − 500
√2
10
= 3.07
If H0 is true, we expect z to be close to 0. If z is far from 0,
there’s evidence against H0 .
Then, the p-value is P = Pr(z ≤ −3.07) + Pr(z ≥ 3.07). Since z
has the standard normal distribution (N (0, 1)) under H0 , we can
find the area under the standard normal probability density
function (pdf).
NB: We only need to find one of the areas above because the
standard normal pdf is symmetric around 0.
24 / 41
Tests of Significance
Calculating p-values
We can find this area from a standard normal table:
25 / 41
Tests of Significance
Calculating p-values
Pr(z ≤ −3.07)
=
0.0011 (from table A)
Pr(z ≥ 3.07)
=
1 − Pr(z ≤ 3.07)
=
1 − 0.9989
=
0.0011 = Pr(z ≤ −3.07)
P
=
Pr(z ≤ −3.07) + Pr(z ≥ 3.07)
=
2Pr(Z ≤ −3.07)
=
0.0022
Now that we obtained the p-value, we need to decide what level of significance
to use in our test. The significance level determines how much evidence we
require to reject H0 , and is usually denoted by the Greek letter alpha, α.
If we choose α = 0.05, rejecting H0 requires evidence so strong that it would
happen no more than 5% of the time if H0 is true. If we choose α = 0.01, we
require even stronger evidence against H0 to be able to reject it: evidence
against H0 would need to be so strong that it would happen only 1% of the
time if H0 is true.
26 / 41
Tests of Significance
P-values and statistical significance
Statistical significance
If the p-value we calculate is smaller than our chosen α, we reject
H0 at significance level α.
Based on this, in our earlier example, we reject the null hypothesis,
H0 , at the 5% level because our p-value of 0.0022 < 0.05.
In fact, we reject H0 even at the 1% level because 0.0022 < 0.01.
This suggests that there is very strong evidence against the null
hypothesis, because if H0 were true, the observed sample mean
should not have happened any more than 1% of the time.
27 / 41
Tests of Significance
One- and two-sided alternative hypotheses
So far, we have focused on two-sided alternative hypotheses where
Ha is stated as µ 6= c, where c is a constant.
In some cases, however, we might be interested in a one-sided
alternative hypothesis. In such cases, Ha would be expressed as
µ < c or µ > c.
28 / 41
Tests of Significance
One- and two-sided alternative hypotheses
In some cases, however, we might be interested in a one-sided alternative
hypothesis. In such cases, Ha would be expressed as µ < c or µ > c.
The p-values then look like this:
28 / 41
Tests of Significance
Summary 1/2
I
Significance tests allow us to formally assess the evidence
against a null hypothesis (H0 ) provided by data. This way, we
can judge whether the deviations from what the null
hypothesis suggests are due to chance.
I
When stating hypotheses, H0 is usually a statement that no
effect exists (e.g. all bottles at a factory are filled with a mean
quantity of 500 ml). The alternative hypothesis, Ha , on the
other hand, suggests that a parameter differs from its null
value in either direction (two-sided alternative) or in a specific
direction (one-sided alternative).
I
The test itself is conducted using a test statistic. The
corresponding p-value is calculated assuming H0 is true, and it
indicates the probability that the test statistic will take a value
at least as "surprising" as the observed one.
29 / 41
Tests of Significance
Summary 2/2
I
Small p-values indicate strong evidence against H0 .
I
If the p-value is smaller than a specified significance level, α,
we reject H0 and conclude that the data are statistically
significant at level α.
I
The test statistic concerning an unknown mean, µ, of a
population are based on the z-statistic calculated as:
z=
x̄ − µ
√σ
n
where x̄ is the sample mean, n is the sample size, and σ is the
known population standard deviation.
30 / 41
Tests of Significance
Standard error
Consider a sample of size n from a normally distributed population
with mean µ and standard deviation σ. As always, the sample
mean is x̄ and is normally distributed with mean µ and standard
deviation √σn .
When σ is unknown, we estimate it using the sample standard
deviation, s. We can then estimate the standard deviation of x̄ as
√s . This quantity is called the standard error of the sample mean,
n
x̄.
Standard Error
Standard deviation of a statistic estimated from the data is
referred to as the standard error of the statistic. The standard
error of the sample mean is
s
SE = √
n
31 / 41
Tests of Significance
z versus t distribution
When σ is known, we can use the familiar z statistic to make
inferences about µ: z = x̄−µ
σ . Recall that this standardized
√
n
statistic has the standard normal distribution, N (0, 1).
When σ is not known, however, we need to estimate it using the
sample standard deviation, s. As a result, we substitute the
standard deviation √σn with the standard error √sn and our test
statistic becomes
t=
x̄ − µ
√s
n
This statistic does not have a standard normal distribution, and
instead follows what’s called a t distribution.
There are lots of t distributions depending on its degrees of
freedom.
32 / 41
Tests of Significance
t distributions
33 / 41
Tests of Significance
z versus t distribution
To use the appropriate t distribution, we need to know the correct
degrees of freedom. In the case of our simple t statistic, this is
simply n − 1, where n is the number of observations in our data
set.
This is because the degrees of freedom come from the sample
standard deviation, s, which has n − 1 degrees of freedom.
Question: Why does s have n − 1 degrees of freedom?
To see why, note that s =
PN
i=1 (xi
q
1
N −1
PN
i=1 (xi
− x̄)2 and that
− x̄) = 0 (i.e. the deviations from the mean sum to zero).
This implies that if we know n − 1 of the deviations, we can
determine the last one. So, technically, only n − 1 deviations can
vary freely and this number (i.e. n − 1) is called the degrees of
freedom.
34 / 41
Confidence Intervals
...using t distributions
Using t distributions allows us to analyze samples from normally
distributed populations without the need to know σ.
As we saw earlier, replacing the standard deviation √σn of x̄ by its
standard error √sn readily converts the z statistic into a t statistic.
All hypothesis tests and confidence intervals can be
conducted/obtained the same way as before simply by using the
appropriate t distribution (i.e. using the correct degrees of
freedom).
More specifically, the margin of error that was z ×
t × √sn .
√σ
n
becomes
35 / 41
Confidence Intervals
...using t distributions
And formally,
t Confidence Interval
A level C confidence interval for a population mean (µ) is
s
x̄ ± t ∗ × √
n
where t ∗ is the critical value with area C between −t ∗ and t ∗ under
the t(n − 1) density curve, and n − 1 is the degrees of freedom.
36 / 41
Confidence Intervals
...using t distributions
Example
Here are monthly dollar amounts for phone service for a random
sample of 8 households: 43, 47, 51, 36, 50, 42, 37, 41. We would
like to construct a 95% CI for the average monthly expenditure, µ.
The sample mean is
43 + 47 + · · · + 41
= 43.5
8
and the
sstandard deviation is
(43 − 43.5)2 + (47 − 43.5)2 + · · · + (41 − 43.5)2
s=
= 5.42
8−1
x̄ =
with degrees of freedom n − 1 = 7. Then, the standard error of x̄ is
s
5.42
SE = √ = √ = 1.92
n
8
37 / 41
Confidence Intervals
...using t distributions
From the t distribution table, we find that t ∗ = 2.365, and thus
the margin of error is
m = 2.365 × SE = (2.365)(1.92) = 4.5
And the 95% confidence interval is
x̄ ± m = 43.5 ± 4.5 = (39, 48)
38 / 41
Confidence Intervals
...using t distributions
39 / 41
Hypothesis tests
...using t distributions
Example
Suppose that the overall U.S. average monthly expenditure for phone service is
$49. Is the sample mean, x̄, of 43.5 different from the national average of $49?
Before we attempt the question, we should state our hypotheses:
H0 : µ = 49
Ha : µ 6= 49
Then, note that x̄ = 43.5, n = 8, and s = 5.42. So, the t test statistic is
x̄ − µ0
43.5 − 49
t=
= −2.87
=
s
5.42
√
n
√
8
Because we have 7 degrees of freedom, this t statistic has the t(7) distribution.
The p-value for this two-sided test is 2P(T ≥ 2.87). From the t table, we see
that P(T ≥ 2.517) = 0.02 and P(T ≥ 2.998) = 0.01. Hence, our p-value is
between 2 × 0.01 = 0.02 and 2 × 0.02 = 0.04. We can obtain the exact value
using a computer, which yields P = 0.0241. This p-value suggests that the
sample mean, x̄, of $43.5 is statistically significantly different from the
nation-wide average of $49 at the 5% level, and that the randomly selected
sample is not in line with the national average.
40 / 41
References
DeGroot, M. H. & Schervish, M. J. (2002). Probability and Statistics.
Addison-Wesley.
Moore, D. et al. (2011). The Practice of Statistics for Business and
Economics. Third Edition. W. H. Freeman.
Stock, J. H. & Watson, M. W. (2010). Introduction to Econometrics. Third
Edition. Pearson Education.
41 / 41