Hypothesis Testing
Hypothesis Testing
TESTING
Dr. Ndwiga
OVERVIEW
Null and Alternative Hypotheses
Test Statistic
P-Value
Significance Level
One-Sample z Test
Power and Sample Size
Terms
Population all possible values
Sample a portion of the population
Statistical inference generalizing from a
sample to a population with calculated degree
of certainty
Two forms of statistical inference
Hypothesis testing
Estimation
Parameter a characteristic of population, e.g.,
population mean µ
Statistic calculated from data in the sample, e.g.,
sample mean ( x )
Distinctions Between
Parameters and Statistics
Parameters Statistics
Vary No Yes
Calculated No Yes
Sampling Distributions of a Mean
x ~ N , SEx
where SEx
n
Hypothesis Testing
Is also called significance testing
Tests a claim about a parameter using evidence (data in a sample
The technique is introduced by considering a one-sample z test
The procedure is broken into four steps
Each element of the procedure must be understood
Hypothesis Testing Steps
A. Null and alternative hypotheses
B. Test statistic
C. P-value and interpretation
D. Significance level (optional)
§9.1 Null and Alternative Hypotheses
x 0 173 170
zstat 0.60
SEx 5
Illustrative Example: z statistic
If we found a sample mean of 185, then
x 0 185 170
zstat 3.00
SEx 5
Reasoning Behind µzstat
x ~ N 170,5
Sampling distribution of xbar
under H0: µ = 170 for n = 64
P-value
The P-value answer the question: What is the
probability of the observed test statistic or one
more extreme when H0 is true?
This corresponds to the AUC in the tail of the
Standard Normal distribution beyond the zstat.
Convert z statistics to P-value :
For Ha: μ > μ0 P = Pr(Z > zstat) = right-tail beyond zstat
For Ha: μ < μ0 P = Pr(Z < zstat) = left tail beyond zstat
For Ha: μ μ0 P = 2 × one-tailed P-value
Use Table B or software to find these
probabilities (next two slides).
One-sided P-value for zstat of 0.6
One-sided P-value for zstat of 3.0
Two-Sided P-Value
One-sided Ha AUC in tail
beyond zstat
Two-sided Ha consider
potential deviations in both
directions double the one-
sided P-value
Examples: If one-sided P
= 0.0010, then two-sided
P = 2 × 0.0010 = 0.0020.
If one-sided P = 0.2743,
then two-sided P = 2 ×
0.2743 = 0.5486.
Interpretation
P-value answer the question: What is the probability of the observed test
statistic … when H0 is true?
Thus, smaller and smaller P-values provide stronger and stronger evidence
against H0
Small P-value strong evidence
Interpretation
Conventions*
P > 0.10 non-significant evidence against H0
0.05 < P 0.10 marginally significant evidence
0.01 < P 0.05 significant evidence against H0
P 0.01 highly significant evidence against H0
Examples
P =.27 non-significant evidence against H0
P =.01 highly significant evidence against H0
x 0
z stat whereSEx
SEx n
Conditions for z test
σ known (not from data)
Population approximately Normal or
large sample (central limit theorem)
SRS (or facsimile)
Data valid
The Lake Wobegon Example
“where all the children are above
average”
15
SEx 5
n 9
x 0 112.8 100
zstat 2.56
SEx 5
C. P-value: P = Pr(Z ≥ 2.56) = 0.0052
Truth
Decision H0 true H0 false
Retain H0 Correct retention Type II error
Reject H0 Type I error Correct rejection
β = Pr(retain H0 | H0 false)
(the “|” is read as “given”)
| | n
1 z1 0 a
2
| 170 190 | 16
1.96
40
0.04
0.5160
Reasoning Behind Power
n
2
z1 z1
2
2
2
where
1 – β ≡ desired power
α ≡ desired significance level (two-sided)
σ ≡ population standard deviation
Δ = μ0 – μa ≡ the difference worth detecting
Example: Sample Size
Requirement
How large a sample is needed for a one-sample z
test with 90% power and α = 0.05 (two-tailed)
when σ = 40? Let H0: μ = 170 and Ha: μ = 190
(thus, Δ = μ0 − μa = 170 – 190 = −20)
n
2
z1 z1
2
2
40 (1.28 1.96)
2 2
41.99
2
20 2