ProbStat2019 07 Testing
ProbStat2019 07 Testing
Statistics
Hypothesis Testing
Ling-Chieh Kung
Introduction
Road map
Statistical hypotheses
H0 : µ = 1
Ha : µ 6= 1.
H0 : p = 0.5.
Ha : p > 0.5.
I Suppose one tends to participate in the election and will give up only if
the chance is slim, the alternative hypothesis will be
Ha : p < 0.5.
Remarks
Road map
H0 : µ = 1000
Ha : µ 6= 1000.
I Once we have a strong evidence supporting Ha , we will claim that
µ 6= 1000.
I Suppose we know the variance of the weights of the products produced:
σ 2 = 40000 g2 .
Rejection rule
Rejection rule
I In this example, the two values 960.8 and 1039.2 are the critical values
for rejection.
I If the sample mean is more extreme than one of the critical values, we
reject H0 .
I Otherwise, we do not reject H0 .
I x̄ = 963 is not strong enough to support Ha : µ 6= 1000.
I Concluding statement:
I Because the sample mean does not lie in the rejection region, we cannot
reject H0 . With a 5% significance level, there is no strong evidence
showing that the average weight is not 1000 g. Based on this result, we
should not shutdown machines and do an inspection.
Summary
I We want to know whether H0 is false, i.e., µ 6= 1000.
I We control the probability of making a wrong conclusion.
I If the machine is actually good, we do not want to reach a conclusion
that requires an inspection and maintenance.
I If H0 (µ = 1000) is true, we do not want to reject H0 .
I We limit the probability at the significance level α = 5%.
I We conclude that H0 is false because the sample mean falls in the
rejection region.
I If the population is normal or if the sample size is large (n ≥ 30), we
have
X −µ
Z= √ ∼ ND(0, 1).
σ/ n
I The calculation of the rejection region (i.e., the critical values) is based
on the z distribution.
I We conducted a z test.
H0 : µ = 1000.
Ha : µ < 1000.
H0 : µ ≥ 1000
Ha : µ < 1000.
I When H0 is true, µ is not fixed to a single value.
I With the rejection region (−∞, 967.1), what is the error probability
Pr(rejecting H0 |H0 is true)?
I If µ = 1000, Pr(rejecting H0 |H0 is true) = 0.05.
I If µ > 1000,
Road map
The p-value
Definition 1
In a hypothesis testing, for an observed value of the statistic, the
p-value is the probability of observing a value that is at least as
extreme as the observed value under the assumption the null
hypothesis is true.
I Based on an observed value of the statistic.
I Is the tail probability of the observed value.
I Assuming that the null hypothesis is true.
The p-value
I Mathematically:
I Suppose we test a population mean µ with a one-tailed test
H0 : µ = 1000
Ha : µ < 1000.
I Given an observed x̄, the p-value is defined as
The p-value
I If H0 is true, i.e., µ = 1000, we have
Pr(X ≤ 963) = Pr(Z ≤ −1.85) = 0.032.
Road map
Type I error
Type II error
I What if the null hypothesis is false? How to avoid not rejecting a false
null hypothesis?
I Not rejecting a false null hypothesis is a Type II error.
I The probability of making a type II error is denoted as β:
Type II error
H0 : µ = 1000.
Ha : µ < 1000.
I If H0 is false and µ is actually 950, we know how to calculate β:
I The rejection rule (which is constructed by assuming H0 is true) will
be the same: Reject H0 if X < 967.1.
I The probability of not rejecting H0 is
α and β
Type II error
Increasing α to decrease β
Road map
X −µ
√ ∼ t(n − 1),
S/ n
X−µ
which means the quantity √
S/ n
follows the t distribution with
degree of freedom n − 1.
I We will use the t test to test the population mean if the population is
normal.
I If the sample size is large, we may still use the z distribution with s
substituting σ.
Example 2
Example 2: hypothesis
I The hypothesis is
H0 : µ = 4.6
Ha : µ 6= 4.6.
I µ is the average score (out of a five-point scale) of NTU restaurants rated
by all NTU students.
I Because the population variance is unknown and the population is
normal, we may use the t test.
I Let Tn ∼ t(n), we calculate the p-value:
4.27 − 4.6
Pr(X < 4.27) = Pr T59 < √ = Pr(T59 < −2.095) = 0.0202.
1.22/ 60
I We may also use the z test because the sample size is large.
I The p-value in the z test is
4.27 − 4.6
Pr(X < 4.27) = Pr Z < √
1.22/ 60
= Pr(Z < −2.095) = 0.01808.
The hypotheses
H0 : p = p0
Ha : p 6= p0 ,
Ha : p > p0
or
Ha : p < p0 .
Sample proportion
I In testing the population proportion p, we base on the sample
proportion Pb and its distribution.
I Reject H0 if the p-value Pr(Pb < p̂) < α (for a left-tailed test).
I Pb is a statistic and p̂ is an observed value of it.
I What is the sampling distribution of Pb?
I Pb is a random variable:
p(1−p)
I E[Pb] = p and Var(Pb) = n
.
I When the sample size is large (n ≥ 30), Pb follows the normal
distribution approximately.
I In practice, it is safer to assume normality if np > 5 and n(1 − p) > 5. As
p is unknown, we check whether np̂ and n(1 − p̂) are greater than five.
I In testing the population proportion, we use the z test.
Example 3
H0 : p = 0.01
Ha : p > 0.01.
I When to adopt Ha : p < 0.01?
Example 3
I Wait!
I The sample proportion Pb is normal with
I Its expectation is 0.01.
q
(0.01)(0.99)
I Its standard error is 1000
= 0.00315.
I One thing is strange...
I The population proportion is p. It should be E[Pb] = p and
Var(Pb) = p(1−p)
n .
I Why do we use p0 = 0.01 to substitute p?
I Why not p̂ = 0.014?
The hypotheses
I The population variance is denoted as σ 2 .
I A two-tailed test for the population proportion is
H0 : σ 2 = σ02
Ha : σ 2 6= σ02 ,
Ha : σ 2 > σ02
or
Ha : σ 2 < σ02
Sample variance
(n − 1)S 2
χ2n−1 = ∼ Chi(n − 1),
σ2
where n is the sample size.
I The population must be normal!
I The test for testing the population variance is thus called a
chi-square test.
I To utilize the chi-square distribution, let’s recall the definition of the
chi-square critical value.
Rejection rule
I Consider a right-tailed test (Ha : σ 2 > σ02 ). With the p-value method,
we will reject H0 if
(n − 1)s2
2
Pr χn−1 > < α.
σ02
(n−1)S 2 (n−1)s2
I
σ2
∼ Chi(n − 1). 2
σ0
is the observed chi-square value.
I The observed sample variance s2 is combined with the hypothesized
population variance σ02 . This is because we assume H0 is true.
I For a two-tailed test, we reject H0 if either
(n − 1)s2 (n − 1)s2
α α
Pr χ2n−1 < < or Pr χ2
n−1 > < .
σ02 2 σ02 2
Example 4
H0 : σ 2 = 10
Ha : σ 2 6= 10.
The sample size is 15 and the sample variance is 18. Let α = 0.05. The
population is normal.
I The observed chi-square value is
(15 − 1) × 18
= 25.2.
10
Remarks